@@ -43,7 +43,7 @@ |
||
43 | 43 | $event = $agenda->get_event($id); |
44 | 44 | |
45 | 45 | if (!empty($event)) { |
46 | - define('ICAL_LANG', api_get_language_isocode()); |
|
46 | + define('ICAL_LANG', api_get_language_isocode()); |
|
47 | 47 | |
48 | 48 | $ical = new vcalendar(); |
49 | 49 | $ical->setConfig('unique_id',api_get_path(WEB_PATH)); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // Login as ... |
21 | 21 | if ($action == "login_as" && !empty ($login_as_user_id)) |
22 | 22 | { |
23 | - login_user($login_as_user_id); |
|
23 | + login_user($login_as_user_id); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | //if we already have a session id and a user... |
@@ -37,150 +37,150 @@ discard block |
||
37 | 37 | |
38 | 38 | if (isset ($_GET['action'])) |
39 | 39 | { |
40 | - $check = Security::check_token('get'); |
|
41 | - if($check) |
|
42 | - { |
|
43 | - switch ($_GET['action']) |
|
44 | - { |
|
45 | - case 'show_message' : |
|
46 | - Display :: display_header($tool_name); |
|
47 | - Display :: display_normal_message($_GET['message']); |
|
48 | - break; |
|
49 | - case 'delete_user' : |
|
50 | - Display :: display_header($tool_name); |
|
51 | - if ($user_id != $_user['user_id'] && UserManager :: delete_user($_GET['user_id'])) |
|
52 | - { |
|
53 | - Display :: display_normal_message(get_lang('UserDeleted')); |
|
54 | - } |
|
55 | - else |
|
56 | - { |
|
57 | - Display :: display_error_message(get_lang('CannotDeleteUser')); |
|
58 | - } |
|
59 | - break; |
|
60 | - case 'lock' : |
|
61 | - Display :: display_header($tool_name); |
|
62 | - $message=lock_unlock_user('lock',$_GET['user_id']); |
|
63 | - Display :: display_normal_message($message); |
|
64 | - break; |
|
65 | - case 'unlock'; |
|
66 | - Display :: display_header($tool_name); |
|
67 | - $message=lock_unlock_user('unlock',$_GET['user_id']); |
|
68 | - Display :: display_normal_message($message); |
|
69 | - break; |
|
70 | - case 'add_user'; |
|
71 | - $id=$_GET['id']; |
|
72 | - $UserList=array(); |
|
73 | - $userid_match_login = array(); |
|
74 | - foreach ($id as $user_id) { |
|
75 | - $tmp = ldap_add_user($user_id); |
|
76 | - $UserList[]= $tmp; |
|
77 | - $userid_match_login[$tmp] = $user_id; |
|
78 | - } |
|
79 | - if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) { |
|
80 | - ldap_add_user_to_session($UserList, $_GET['id_session']); |
|
81 | - header('Location: resume_session.php?id_session='.intval($_GET['id_session'])); |
|
82 | - } else { |
|
83 | - Display :: display_header($tool_name); |
|
84 | - if(count($userid_match_login)>0) |
|
85 | - { |
|
86 | - $message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
|
87 | - foreach($userid_match_login as $user_id => $login) |
|
88 | - { |
|
89 | - $message .= '- '.$login.'<br />'; |
|
90 | - } |
|
91 | - } |
|
92 | - else |
|
93 | - { |
|
94 | - $message=get_lang('NoUserAdded'); |
|
95 | - } |
|
96 | - Display :: display_normal_message($message,false); |
|
97 | - } |
|
98 | - break; |
|
99 | - default : |
|
100 | - Display :: display_header($tool_name); |
|
101 | - } |
|
102 | - Security::clear_token(); |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - Display::display_header($tool_name); |
|
107 | - } |
|
40 | + $check = Security::check_token('get'); |
|
41 | + if($check) |
|
42 | + { |
|
43 | + switch ($_GET['action']) |
|
44 | + { |
|
45 | + case 'show_message' : |
|
46 | + Display :: display_header($tool_name); |
|
47 | + Display :: display_normal_message($_GET['message']); |
|
48 | + break; |
|
49 | + case 'delete_user' : |
|
50 | + Display :: display_header($tool_name); |
|
51 | + if ($user_id != $_user['user_id'] && UserManager :: delete_user($_GET['user_id'])) |
|
52 | + { |
|
53 | + Display :: display_normal_message(get_lang('UserDeleted')); |
|
54 | + } |
|
55 | + else |
|
56 | + { |
|
57 | + Display :: display_error_message(get_lang('CannotDeleteUser')); |
|
58 | + } |
|
59 | + break; |
|
60 | + case 'lock' : |
|
61 | + Display :: display_header($tool_name); |
|
62 | + $message=lock_unlock_user('lock',$_GET['user_id']); |
|
63 | + Display :: display_normal_message($message); |
|
64 | + break; |
|
65 | + case 'unlock'; |
|
66 | + Display :: display_header($tool_name); |
|
67 | + $message=lock_unlock_user('unlock',$_GET['user_id']); |
|
68 | + Display :: display_normal_message($message); |
|
69 | + break; |
|
70 | + case 'add_user'; |
|
71 | + $id=$_GET['id']; |
|
72 | + $UserList=array(); |
|
73 | + $userid_match_login = array(); |
|
74 | + foreach ($id as $user_id) { |
|
75 | + $tmp = ldap_add_user($user_id); |
|
76 | + $UserList[]= $tmp; |
|
77 | + $userid_match_login[$tmp] = $user_id; |
|
78 | + } |
|
79 | + if (isset($_GET['id_session']) && ($_GET['id_session'] == strval(intval($_GET['id_session']))) && ($_GET['id_session']>0)) { |
|
80 | + ldap_add_user_to_session($UserList, $_GET['id_session']); |
|
81 | + header('Location: resume_session.php?id_session='.intval($_GET['id_session'])); |
|
82 | + } else { |
|
83 | + Display :: display_header($tool_name); |
|
84 | + if(count($userid_match_login)>0) |
|
85 | + { |
|
86 | + $message=get_lang('LDAPUsersAddedOrUpdated').':<br />'; |
|
87 | + foreach($userid_match_login as $user_id => $login) |
|
88 | + { |
|
89 | + $message .= '- '.$login.'<br />'; |
|
90 | + } |
|
91 | + } |
|
92 | + else |
|
93 | + { |
|
94 | + $message=get_lang('NoUserAdded'); |
|
95 | + } |
|
96 | + Display :: display_normal_message($message,false); |
|
97 | + } |
|
98 | + break; |
|
99 | + default : |
|
100 | + Display :: display_header($tool_name); |
|
101 | + } |
|
102 | + Security::clear_token(); |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + Display::display_header($tool_name); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - Display::display_header($tool_name); |
|
111 | + Display::display_header($tool_name); |
|
112 | 112 | } |
113 | 113 | if (isset ($_POST['action'])) |
114 | 114 | { |
115 | - $check = Security::check_token('get'); |
|
116 | - if($check) |
|
117 | - { |
|
118 | - switch ($_POST['action']) |
|
119 | - { |
|
120 | - case 'delete' : |
|
121 | - $number_of_selected_users = count($_POST['id']); |
|
122 | - $number_of_deleted_users = 0; |
|
123 | - foreach ($_POST['id'] as $index => $user_id) |
|
124 | - { |
|
125 | - if($user_id != $_user['user_id']) |
|
126 | - { |
|
127 | - if(UserManager :: delete_user($user_id)) |
|
128 | - { |
|
129 | - $number_of_deleted_users++; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
133 | - if($number_of_selected_users == $number_of_deleted_users) |
|
134 | - { |
|
135 | - Display :: display_normal_message(get_lang('SelectedUsersDeleted')); |
|
136 | - } |
|
137 | - else |
|
138 | - { |
|
139 | - Display :: display_error_message(get_lang('SomeUsersNotDeleted')); |
|
140 | - } |
|
141 | - break; |
|
142 | - case 'add_user' : |
|
143 | - $number_of_selected_users = count($_POST['id']); |
|
144 | - $number_of_added_users = 0; |
|
145 | - $UserList=array(); |
|
146 | - foreach ($_POST['id'] as $index => $user_id) |
|
147 | - { |
|
148 | - if($user_id != $_user['user_id']) |
|
149 | - { |
|
150 | - $UserList[] = ldap_add_user($user_id); |
|
151 | - } |
|
152 | - } |
|
153 | - if (isset($_GET['id_session']) && (trim($_GET['id_session'])!="")) |
|
154 | - addUserToSession($UserList, $_GET['id_session']); |
|
155 | - if(count($UserList)>0) |
|
156 | - { |
|
157 | - Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
|
158 | - } |
|
159 | - else |
|
160 | - { |
|
161 | - Display :: display_normal_message(get_lang('NoUserAdded')); |
|
162 | - } |
|
163 | - break; |
|
115 | + $check = Security::check_token('get'); |
|
116 | + if($check) |
|
117 | + { |
|
118 | + switch ($_POST['action']) |
|
119 | + { |
|
120 | + case 'delete' : |
|
121 | + $number_of_selected_users = count($_POST['id']); |
|
122 | + $number_of_deleted_users = 0; |
|
123 | + foreach ($_POST['id'] as $index => $user_id) |
|
124 | + { |
|
125 | + if($user_id != $_user['user_id']) |
|
126 | + { |
|
127 | + if(UserManager :: delete_user($user_id)) |
|
128 | + { |
|
129 | + $number_of_deleted_users++; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | + if($number_of_selected_users == $number_of_deleted_users) |
|
134 | + { |
|
135 | + Display :: display_normal_message(get_lang('SelectedUsersDeleted')); |
|
136 | + } |
|
137 | + else |
|
138 | + { |
|
139 | + Display :: display_error_message(get_lang('SomeUsersNotDeleted')); |
|
140 | + } |
|
141 | + break; |
|
142 | + case 'add_user' : |
|
143 | + $number_of_selected_users = count($_POST['id']); |
|
144 | + $number_of_added_users = 0; |
|
145 | + $UserList=array(); |
|
146 | + foreach ($_POST['id'] as $index => $user_id) |
|
147 | + { |
|
148 | + if($user_id != $_user['user_id']) |
|
149 | + { |
|
150 | + $UserList[] = ldap_add_user($user_id); |
|
151 | + } |
|
152 | + } |
|
153 | + if (isset($_GET['id_session']) && (trim($_GET['id_session'])!="")) |
|
154 | + addUserToSession($UserList, $_GET['id_session']); |
|
155 | + if(count($UserList)>0) |
|
156 | + { |
|
157 | + Display :: display_normal_message(count($UserList)." ".get_lang('LDAPUsersAdded')); |
|
158 | + } |
|
159 | + else |
|
160 | + { |
|
161 | + Display :: display_normal_message(get_lang('NoUserAdded')); |
|
162 | + } |
|
163 | + break; |
|
164 | 164 | |
165 | - } |
|
166 | - Security::clear_token(); |
|
167 | - } |
|
165 | + } |
|
166 | + Security::clear_token(); |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $form = new FormValidator('advanced_search','get'); |
171 | 171 | $form->addText('keyword_username',get_lang('LoginName'),false); |
172 | 172 | if (api_is_western_name_order()) |
173 | 173 | { |
174 | - $form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
175 | - $form->addText('keyword_lastname', get_lang('LastName'), false); |
|
174 | + $form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
175 | + $form->addText('keyword_lastname', get_lang('LastName'), false); |
|
176 | 176 | } |
177 | 177 | else |
178 | 178 | { |
179 | - $form->addText('keyword_lastname',get_lang('LastName'),false); |
|
180 | - $form->addText('keyword_firstname',get_lang('FirstName'),false); |
|
179 | + $form->addText('keyword_lastname',get_lang('LastName'),false); |
|
180 | + $form->addText('keyword_firstname',get_lang('FirstName'),false); |
|
181 | 181 | } |
182 | 182 | if (isset($_GET['id_session'])) |
183 | - $form->addElement('hidden','id_session',$_GET['id_session']); |
|
183 | + $form->addElement('hidden','id_session',$_GET['id_session']); |
|
184 | 184 | |
185 | 185 | $type = array(); |
186 | 186 | $type["all"] = get_lang('All'); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $parameters['keyword_lastname'] = @$_GET['keyword_lastname'] ?: null; |
203 | 203 | $parameters['keyword_email'] = @$_GET['keyword_email'] ?: null; |
204 | 204 | if (isset($_GET['id_session'])) |
205 | - $parameters['id_session'] = $_GET['id_session']; |
|
205 | + $parameters['id_session'] = $_GET['id_session']; |
|
206 | 206 | // Create a sortable table with user-data |
207 | 207 | |
208 | 208 | $parameters['sec_token'] = Security::get_token(); |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $table->set_header(1, get_lang('LoginName')); |
213 | 213 | if (api_is_western_name_order()) |
214 | 214 | { |
215 | - $table->set_header(2, get_lang('FirstName')); |
|
216 | - $table->set_header(3, get_lang('LastName')); |
|
215 | + $table->set_header(2, get_lang('FirstName')); |
|
216 | + $table->set_header(3, get_lang('LastName')); |
|
217 | 217 | } |
218 | 218 | else |
219 | 219 | { |
220 | - $table->set_header(2, get_lang('LastName')); |
|
221 | - $table->set_header(3, get_lang('FirstName')); |
|
220 | + $table->set_header(2, get_lang('LastName')); |
|
221 | + $table->set_header(3, get_lang('FirstName')); |
|
222 | 222 | } |
223 | 223 | $table->set_header(4, get_lang('Email')); |
224 | 224 | $table->set_header(5, get_lang('Actions')); |
@@ -6,47 +6,47 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class AddCourseToSession |
8 | 8 | { |
9 | - /** |
|
10 | - * Searches a course, given a search string and a type of search box |
|
11 | - * @param string $needle Search string |
|
12 | - * @param string $type Type of search box ('single' or anything else) |
|
13 | - * @return xajaxResponse XajaxResponse |
|
14 | - * @assert ('abc', 'single') !== null |
|
15 | - * @assert ('abc', 'multiple') !== null |
|
16 | - */ |
|
17 | - public static function search_courses($needle, $type) |
|
18 | - { |
|
19 | - global $tbl_session_rel_course, $id_session; |
|
9 | + /** |
|
10 | + * Searches a course, given a search string and a type of search box |
|
11 | + * @param string $needle Search string |
|
12 | + * @param string $type Type of search box ('single' or anything else) |
|
13 | + * @return xajaxResponse XajaxResponse |
|
14 | + * @assert ('abc', 'single') !== null |
|
15 | + * @assert ('abc', 'multiple') !== null |
|
16 | + */ |
|
17 | + public static function search_courses($needle, $type) |
|
18 | + { |
|
19 | + global $tbl_session_rel_course, $id_session; |
|
20 | 20 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
21 | - $course_title = null; |
|
22 | - $xajax_response = new xajaxResponse(); |
|
23 | - $return = ''; |
|
24 | - if(!empty($needle) && !empty($type)) { |
|
25 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | - $charset = api_get_system_encoding(); |
|
27 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
21 | + $course_title = null; |
|
22 | + $xajax_response = new xajaxResponse(); |
|
23 | + $return = ''; |
|
24 | + if(!empty($needle) && !empty($type)) { |
|
25 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | + $charset = api_get_system_encoding(); |
|
27 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
28 | 28 | |
29 | - $cond_course_code = ''; |
|
30 | - if (!empty($id_session)) { |
|
31 | - $id_session = intval($id_session); |
|
32 | - // check course_code from session_rel_course table |
|
33 | - $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
29 | + $cond_course_code = ''; |
|
30 | + if (!empty($id_session)) { |
|
31 | + $id_session = intval($id_session); |
|
32 | + // check course_code from session_rel_course table |
|
33 | + $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
34 | 34 | WHERE session_id = '.$id_session; |
35 | - $res = Database::query($sql); |
|
36 | - $course_codes = ''; |
|
37 | - if (Database::num_rows($res) > 0) { |
|
38 | - while ($row = Database::fetch_row($res)) { |
|
39 | - $course_codes .= '\''.$row[0].'\','; |
|
40 | - } |
|
41 | - $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
35 | + $res = Database::query($sql); |
|
36 | + $course_codes = ''; |
|
37 | + if (Database::num_rows($res) > 0) { |
|
38 | + while ($row = Database::fetch_row($res)) { |
|
39 | + $course_codes .= '\''.$row[0].'\','; |
|
40 | + } |
|
41 | + $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
42 | 42 | |
43 | - $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | - } |
|
45 | - } |
|
43 | + $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | if ($type == 'single') { |
48 | - // search users where username or firstname or lastname begins likes $needle |
|
49 | - $sql = 'SELECT |
|
48 | + // search users where username or firstname or lastname begins likes $needle |
|
49 | + $sql = 'SELECT |
|
50 | 50 | course.id, |
51 | 51 | course.visual_code, |
52 | 52 | course.title, |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | WHERE |
59 | 59 | course.visual_code LIKE "'.$needle.'%" OR |
60 | 60 | course.title LIKE "'.$needle.'%"'; |
61 | - } else { |
|
61 | + } else { |
|
62 | 62 | $sql = 'SELECT course.id, course.visual_code, course.title |
63 | 63 | FROM '.$tbl_course.' course |
64 | 64 | WHERE |
65 | 65 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
66 | 66 | ORDER BY course.code '; |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - if (api_is_multiple_url_enabled()) { |
|
70 | - $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | - $access_url_id = api_get_current_access_url_id(); |
|
72 | - if ($access_url_id != -1){ |
|
69 | + if (api_is_multiple_url_enabled()) { |
|
70 | + $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | + $access_url_id = api_get_current_access_url_id(); |
|
72 | + if ($access_url_id != -1){ |
|
73 | 73 | |
74 | - if ($type=='single') { |
|
75 | - $sql = 'SELECT |
|
74 | + if ($type=='single') { |
|
75 | + $sql = 'SELECT |
|
76 | 76 | course.id, |
77 | 77 | course.visual_code, |
78 | 78 | course.title, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | access_url_id = '.$access_url_id.' AND |
88 | 88 | (course.visual_code LIKE "'.$needle.'%" OR |
89 | 89 | course.title LIKE "'.$needle.'%" )'; |
90 | - } else { |
|
90 | + } else { |
|
91 | 91 | $sql = 'SELECT course.id, course.visual_code, course.title |
92 | 92 | FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course |
93 | 93 | WHERE |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | access_url_id = '.$access_url_id.' AND |
96 | 96 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
97 | 97 | ORDER BY course.code '; |
98 | - } |
|
99 | - } |
|
100 | - } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - $rs = Database::query($sql); |
|
103 | - $course_list = array(); |
|
102 | + $rs = Database::query($sql); |
|
103 | + $course_list = array(); |
|
104 | 104 | if ($type == 'single') { |
105 | - while ($course = Database :: fetch_array($rs)) { |
|
106 | - $course_list[] = $course['code']; |
|
107 | - $course_title=str_replace("'","\'",$course_title); |
|
105 | + while ($course = Database :: fetch_array($rs)) { |
|
106 | + $course_list[] = $course['code']; |
|
107 | + $course_title=str_replace("'","\'",$course_title); |
|
108 | 108 | $return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['id'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />'; |
109 | - } |
|
110 | - $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
111 | - } else { |
|
112 | - $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
113 | - while($course = Database :: fetch_array($rs)) { |
|
114 | - $course_list[] = $course['code']; |
|
115 | - $course_title=str_replace("'","\'",$course_title); |
|
109 | + } |
|
110 | + $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
111 | + } else { |
|
112 | + $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
113 | + while($course = Database :: fetch_array($rs)) { |
|
114 | + $course_list[] = $course['code']; |
|
115 | + $course_title=str_replace("'","\'",$course_title); |
|
116 | 116 | $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>'; |
117 | - } |
|
118 | - $return .= '</select>'; |
|
119 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
120 | - } |
|
121 | - } |
|
122 | - $_SESSION['course_list'] = $course_list; |
|
117 | + } |
|
118 | + $return .= '</select>'; |
|
119 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
120 | + } |
|
121 | + } |
|
122 | + $_SESSION['course_list'] = $course_list; |
|
123 | 123 | |
124 | - return $xajax_response; |
|
125 | - } |
|
124 | + return $xajax_response; |
|
125 | + } |
|
126 | 126 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | if (!$is_allowedToEdit) { |
47 | - // api_not_allowed(); |
|
47 | + // api_not_allowed(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if (!empty($_REQUEST['path'])) { |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | get_lang('Actions') |
190 | 190 | ); |
191 | 191 | |
192 | - // Column config |
|
193 | - // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
192 | + // Column config |
|
193 | + // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
194 | 194 | $column_model = array( |
195 | 195 | array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'), |
196 | 196 | array( |
@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | $sublanguage_folder_error = false; |
67 | 67 | |
68 | 68 | if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
69 | - $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | - $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | - $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | - $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | - $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
69 | + $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | + $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | + $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | + $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | + $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
74 | 74 | |
75 | - if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | - $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | - } |
|
78 | - if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | - $language_id_exist = true; |
|
80 | - } else { |
|
81 | - $language_id_exist = false; |
|
82 | - } |
|
75 | + if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | + $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | + } |
|
78 | + if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | + $language_id_exist = true; |
|
80 | + } else { |
|
81 | + $language_id_exist = false; |
|
82 | + } |
|
83 | 83 | } else { |
84 | - $language_name=''; |
|
85 | - $language_id_exist=false; |
|
84 | + $language_name=''; |
|
85 | + $language_id_exist=false; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $intro = sprintf(get_lang('RegisterTermsOfSubLanguageForX'), strtolower($sub_language_name)); |
89 | 89 | $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder']; |
90 | 90 | |
91 | 91 | if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { |
92 | - api_not_allowed(true); |
|
92 | + api_not_allowed(true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | Display :: display_header($language_name); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | echo $html; |
115 | 115 | echo '<br /><br /><br />'; |
116 | 116 | if (!empty($sublanguage_folder_error)) { |
117 | - Display::display_warning_message($sublanguage_folder_error); |
|
117 | + Display::display_warning_message($sublanguage_folder_error); |
|
118 | 118 | } |
119 | 119 | echo '<div id="div_message_information_id"> </div>'; |
120 | 120 | |
@@ -128,186 +128,186 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | function search_language_term( |
131 | - $term, |
|
132 | - $search_in_variable = true, |
|
133 | - $search_in_english = true, |
|
134 | - $search_in_parent = true, |
|
135 | - $search_in_sub_language = true |
|
131 | + $term, |
|
132 | + $search_in_variable = true, |
|
133 | + $search_in_english = true, |
|
134 | + $search_in_parent = true, |
|
135 | + $search_in_sub_language = true |
|
136 | 136 | ) { |
137 | - //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
138 | - /* |
|
137 | + //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
138 | + /* |
|
139 | 139 | These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php |
140 | 140 | $english_language_array |
141 | 141 | $parent_language_array |
142 | 142 | $sub_language_array |
143 | 143 | $language_files_to_load |
144 | 144 | */ |
145 | - global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
146 | - $language_files_to_load_keys = array_flip($language_files_to_load); |
|
147 | - $array_to_search = $parent_language_array; |
|
148 | - $list_info = array(); |
|
149 | - $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
150 | - //@todo optimize this foreach |
|
151 | - foreach ($language_files_to_load as $lang_file) { |
|
152 | - //searching in parent language of the sub language |
|
153 | - if ($search_in_parent) { |
|
154 | - $variables = $parent_language_array[$lang_file]; |
|
155 | - foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
156 | - //arrays are avoided |
|
157 | - if (is_array($parent_variable_value)) { |
|
158 | - continue; |
|
159 | - } |
|
160 | - $founded = false; |
|
161 | - // searching the item in the parent tool |
|
162 | - if (preg_match($term,$parent_variable_value)!==0) { |
|
163 | - $founded = true; |
|
164 | - } |
|
165 | - if ($founded) { |
|
166 | - //loading variable from the english array |
|
167 | - $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
168 | - //loading variable from the english array |
|
169 | - $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
145 | + global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
146 | + $language_files_to_load_keys = array_flip($language_files_to_load); |
|
147 | + $array_to_search = $parent_language_array; |
|
148 | + $list_info = array(); |
|
149 | + $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
150 | + //@todo optimize this foreach |
|
151 | + foreach ($language_files_to_load as $lang_file) { |
|
152 | + //searching in parent language of the sub language |
|
153 | + if ($search_in_parent) { |
|
154 | + $variables = $parent_language_array[$lang_file]; |
|
155 | + foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
156 | + //arrays are avoided |
|
157 | + if (is_array($parent_variable_value)) { |
|
158 | + continue; |
|
159 | + } |
|
160 | + $founded = false; |
|
161 | + // searching the item in the parent tool |
|
162 | + if (preg_match($term,$parent_variable_value)!==0) { |
|
163 | + $founded = true; |
|
164 | + } |
|
165 | + if ($founded) { |
|
166 | + //loading variable from the english array |
|
167 | + $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
168 | + //loading variable from the english array |
|
169 | + $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
170 | 170 | |
171 | - //config buttons |
|
172 | - /*if (strlen($english_name_variable)>1500) { |
|
171 | + //config buttons |
|
172 | + /*if (strlen($english_name_variable)>1500) { |
|
173 | 173 | $size =20; |
174 | 174 | } else { |
175 | 175 | $size =4; |
176 | 176 | }*/ |
177 | 177 | |
178 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
179 | - $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
178 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
179 | + $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
180 | 180 | |
181 | - $list_info[] = array( |
|
182 | - $lang_file . '.inc.php', |
|
183 | - $parent_name_variable, |
|
184 | - $english_name_variable, |
|
185 | - $parent_variable_value, |
|
186 | - $obj_text, |
|
187 | - $obj_button |
|
188 | - ); |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
181 | + $list_info[] = array( |
|
182 | + $lang_file . '.inc.php', |
|
183 | + $parent_name_variable, |
|
184 | + $english_name_variable, |
|
185 | + $parent_variable_value, |
|
186 | + $obj_text, |
|
187 | + $obj_button |
|
188 | + ); |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | 192 | |
193 | - //search in english |
|
194 | - if ($search_in_english || $search_in_variable) { |
|
195 | - $variables = $english_language_array[$lang_file]; |
|
196 | - foreach ($variables as $name_variable =>$variable_value) { |
|
197 | - if (is_array($variable_value)) { |
|
198 | - continue; |
|
199 | - } |
|
193 | + //search in english |
|
194 | + if ($search_in_english || $search_in_variable) { |
|
195 | + $variables = $english_language_array[$lang_file]; |
|
196 | + foreach ($variables as $name_variable =>$variable_value) { |
|
197 | + if (is_array($variable_value)) { |
|
198 | + continue; |
|
199 | + } |
|
200 | 200 | |
201 | - if (is_array($variable_value)) |
|
202 | - echo $lang_file; |
|
203 | - $founded = false; |
|
204 | - if ($search_in_english && $search_in_variable) { |
|
205 | - // searching the item in the parent tool |
|
206 | - if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
207 | - $founded = true; |
|
208 | - } |
|
209 | - } else { |
|
210 | - if ($search_in_english) { |
|
211 | - if (preg_match($term,$variable_value)!==0) { |
|
212 | - $founded = true; |
|
213 | - } |
|
214 | - } else { |
|
215 | - if (preg_match($term,$name_variable)!==0) { |
|
216 | - $founded = true; |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
201 | + if (is_array($variable_value)) |
|
202 | + echo $lang_file; |
|
203 | + $founded = false; |
|
204 | + if ($search_in_english && $search_in_variable) { |
|
205 | + // searching the item in the parent tool |
|
206 | + if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
207 | + $founded = true; |
|
208 | + } |
|
209 | + } else { |
|
210 | + if ($search_in_english) { |
|
211 | + if (preg_match($term,$variable_value)!==0) { |
|
212 | + $founded = true; |
|
213 | + } |
|
214 | + } else { |
|
215 | + if (preg_match($term,$name_variable)!==0) { |
|
216 | + $founded = true; |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - if ($founded) { |
|
222 | - //loading variable from the english array |
|
223 | - $sub_language_name_variable = null; |
|
224 | - if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
225 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
226 | - } |
|
227 | - $parent_variable_value = null; |
|
228 | - if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
229 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
230 | - } |
|
231 | - //config buttons |
|
232 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
233 | - $sub_language_name_variable.' |
|
221 | + if ($founded) { |
|
222 | + //loading variable from the english array |
|
223 | + $sub_language_name_variable = null; |
|
224 | + if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
225 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
226 | + } |
|
227 | + $parent_variable_value = null; |
|
228 | + if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
229 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
230 | + } |
|
231 | + //config buttons |
|
232 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
233 | + $sub_language_name_variable.' |
|
234 | 234 | </textarea>'; |
235 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
235 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
236 | 236 | |
237 | - //loading variable from the english array |
|
238 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
237 | + //loading variable from the english array |
|
238 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
239 | 239 | |
240 | - $list_info[] = array( |
|
241 | - $lang_file . '.inc.php', |
|
242 | - $name_variable, |
|
243 | - $english_name_variable, |
|
244 | - $parent_variable_value, |
|
245 | - $obj_text, |
|
246 | - $obj_button |
|
247 | - ); |
|
248 | - } |
|
249 | - } |
|
250 | - } |
|
240 | + $list_info[] = array( |
|
241 | + $lang_file . '.inc.php', |
|
242 | + $name_variable, |
|
243 | + $english_name_variable, |
|
244 | + $parent_variable_value, |
|
245 | + $obj_text, |
|
246 | + $obj_button |
|
247 | + ); |
|
248 | + } |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - // Search in sub language |
|
253 | - if ($search_in_sub_language) { |
|
254 | - $variables = $sub_language_array[$lang_file]; |
|
255 | - foreach ($variables as $name_variable =>$variable_value) { |
|
256 | - if (is_array($parent_variable_value)) { |
|
257 | - continue; |
|
258 | - } |
|
252 | + // Search in sub language |
|
253 | + if ($search_in_sub_language) { |
|
254 | + $variables = $sub_language_array[$lang_file]; |
|
255 | + foreach ($variables as $name_variable =>$variable_value) { |
|
256 | + if (is_array($parent_variable_value)) { |
|
257 | + continue; |
|
258 | + } |
|
259 | 259 | |
260 | - if (is_array($variable_value)) { |
|
261 | - continue; |
|
262 | - } |
|
260 | + if (is_array($variable_value)) { |
|
261 | + continue; |
|
262 | + } |
|
263 | 263 | |
264 | - $founded = false; |
|
265 | - // searching the item in the parent tool |
|
266 | - if (preg_match($term,$variable_value)!==0) { |
|
267 | - $founded = true; |
|
268 | - } |
|
269 | - if ($founded) { |
|
270 | - //loading variable from the english array |
|
271 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
272 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
273 | - //config buttons |
|
274 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
275 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
264 | + $founded = false; |
|
265 | + // searching the item in the parent tool |
|
266 | + if (preg_match($term,$variable_value)!==0) { |
|
267 | + $founded = true; |
|
268 | + } |
|
269 | + if ($founded) { |
|
270 | + //loading variable from the english array |
|
271 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
272 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
273 | + //config buttons |
|
274 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
275 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
276 | 276 | |
277 | - //loading variable from the english array |
|
278 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
279 | - $list_info[]=array($lang_file.'.inc.php', |
|
280 | - $name_variable, |
|
281 | - $english_name_variable, |
|
282 | - $parent_variable_value,$obj_text,$obj_button); |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
277 | + //loading variable from the english array |
|
278 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
279 | + $list_info[]=array($lang_file.'.inc.php', |
|
280 | + $name_variable, |
|
281 | + $english_name_variable, |
|
282 | + $parent_variable_value,$obj_text,$obj_button); |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | 287 | |
288 | - $list_info = array_unique_dimensional($list_info); |
|
289 | - return $list_info; |
|
288 | + $list_info = array_unique_dimensional($list_info); |
|
289 | + return $list_info; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Allow see data in sort table |
293 | 293 | $list_info = array(); |
294 | 294 | if (isset($_REQUEST['txt_search_word'])) { |
295 | - //@todo fix to accept a char with 1 char |
|
296 | - if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
297 | - $list_info = search_language_term( |
|
298 | - $_REQUEST['txt_search_word'], |
|
299 | - true, |
|
300 | - true, |
|
301 | - true, |
|
302 | - true |
|
303 | - ); |
|
304 | - } |
|
295 | + //@todo fix to accept a char with 1 char |
|
296 | + if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
297 | + $list_info = search_language_term( |
|
298 | + $_REQUEST['txt_search_word'], |
|
299 | + true, |
|
300 | + true, |
|
301 | + true, |
|
302 | + true |
|
303 | + ); |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $parameters = array( |
308 | - 'id' => intval($_GET['id']), |
|
309 | - 'sub_language_id' => intval($_GET['sub_language_id']), |
|
310 | - 'txt_search_word' => $txt_search_word |
|
308 | + 'id' => intval($_GET['id']), |
|
309 | + 'sub_language_id' => intval($_GET['sub_language_id']), |
|
310 | + 'txt_search_word' => $txt_search_word |
|
311 | 311 | ); |
312 | 312 | $table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); |
313 | 313 | $table->set_additional_parameters($parameters); |
@@ -99,27 +99,27 @@ discard block |
||
99 | 99 | $form = new FormValidator('user_add'); |
100 | 100 | $form->addElement('header', '', $tool_name); |
101 | 101 | if (api_is_western_name_order()) { |
102 | - // Firstname |
|
103 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
104 | - $form->applyFilter('firstname', 'html_filter'); |
|
105 | - $form->applyFilter('firstname', 'trim'); |
|
106 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
107 | - // Lastname |
|
108 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
109 | - $form->applyFilter('lastname', 'html_filter'); |
|
110 | - $form->applyFilter('lastname', 'trim'); |
|
111 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
102 | + // Firstname |
|
103 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
104 | + $form->applyFilter('firstname', 'html_filter'); |
|
105 | + $form->applyFilter('firstname', 'trim'); |
|
106 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
107 | + // Lastname |
|
108 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
109 | + $form->applyFilter('lastname', 'html_filter'); |
|
110 | + $form->applyFilter('lastname', 'trim'); |
|
111 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
112 | 112 | } else { |
113 | - // Lastname |
|
114 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
115 | - $form->applyFilter('lastname', 'html_filter'); |
|
116 | - $form->applyFilter('lastname', 'trim'); |
|
117 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
118 | - // Firstname |
|
119 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
120 | - $form->applyFilter('firstname', 'html_filter'); |
|
121 | - $form->applyFilter('firstname', 'trim'); |
|
122 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
113 | + // Lastname |
|
114 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
115 | + $form->applyFilter('lastname', 'html_filter'); |
|
116 | + $form->applyFilter('lastname', 'trim'); |
|
117 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
118 | + // Firstname |
|
119 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
120 | + $form->applyFilter('firstname', 'html_filter'); |
|
121 | + $form->applyFilter('firstname', 'trim'); |
|
122 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
123 | 123 | } |
124 | 124 | // Official code |
125 | 125 | $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => '40')); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $auth_sources = 0; //make available wider as we need it in case of form reset (see below) |
164 | 164 | $nb_ext_auth_source_added = 0; |
165 | 165 | if (isset($extAuthSource) && count($extAuthSource) > 0) { |
166 | - $auth_sources = array(); |
|
166 | + $auth_sources = array(); |
|
167 | 167 | foreach ($extAuthSource as $key => $info) { |
168 | 168 | // @todo : make uniform external authentification configuration (ex : cas and external_login ldap) |
169 | 169 | // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | $nb_ext_auth_source_added++; |
175 | 175 | } |
176 | 176 | } |
177 | - if ($nb_ext_auth_source_added > 0) { |
|
178 | - $group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); |
|
179 | - $group[] = $form->createElement('select', 'auth_source', null, $auth_sources); |
|
180 | - $group[] = $form->createElement('static', '', '', '<br />'); |
|
177 | + if ($nb_ext_auth_source_added > 0) { |
|
178 | + $group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); |
|
179 | + $group[] = $form->createElement('select', 'auth_source', null, $auth_sources); |
|
180 | + $group[] = $form->createElement('static', '', '', '<br />'); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | $form->addElement('html', '<div id="drh_list" style="display:'.$display.';">'); |
247 | 247 | |
248 | 248 | if (isset($drh_list) && is_array($drh_list)) { |
249 | - foreach ($drh_list as $drh) { |
|
249 | + foreach ($drh_list as $drh) { |
|
250 | 250 | $drh_select->addOption( |
251 | 251 | api_get_person_name($drh['firstname'], $drh['lastname']), |
252 | 252 | $drh['user_id'] |
253 | 253 | ); |
254 | - } |
|
254 | + } |
|
255 | 255 | } |
256 | 256 | $form->addElement('html', '</div>'); |
257 | 257 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | // Validate form |
327 | 327 | if ($form->validate()) { |
328 | - $check = Security::check_token('post'); |
|
328 | + $check = Security::check_token('post'); |
|
329 | 329 | if ($check) { |
330 | 330 | $user = $form->exportValues(); |
331 | 331 | $lastname = $user['lastname']; |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | $send_mail = intval($user['mail']['send_mail']); |
342 | 342 | $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : 0; |
343 | 343 | |
344 | - if (isset($extAuthSource) && count($extAuthSource) > 0 && |
|
344 | + if (isset($extAuthSource) && count($extAuthSource) > 0 && |
|
345 | 345 | $user['password']['password_auto'] == '2' |
346 | 346 | ) { |
347 | - $auth_source = $user['password']['auth_source']; |
|
348 | - $password = 'PLACEHOLDER'; |
|
349 | - } else { |
|
350 | - $auth_source = PLATFORM_AUTH_SOURCE; |
|
351 | - $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
352 | - } |
|
347 | + $auth_source = $user['password']['auth_source']; |
|
348 | + $password = 'PLACEHOLDER'; |
|
349 | + } else { |
|
350 | + $auth_source = PLATFORM_AUTH_SOURCE; |
|
351 | + $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
352 | + } |
|
353 | 353 | |
354 | 354 | if ($user['radio_expiration_date'] == '1') { |
355 | 355 | $expiration_date = $user['expiration_date']; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $expiration_date = null; |
358 | 358 | } |
359 | 359 | |
360 | - $active = intval($user['active']); |
|
360 | + $active = intval($user['active']); |
|
361 | 361 | |
362 | 362 | if (api_get_setting('login_is_email') == 'true') { |
363 | 363 | $username = $email; |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | $extra, |
389 | 389 | null, |
390 | 390 | $send_mail, |
391 | - $platform_admin |
|
391 | + $platform_admin |
|
392 | 392 | ); |
393 | 393 | |
394 | - Security::clear_token(); |
|
395 | - $tok = Security::get_token(); |
|
396 | - if (!empty($user_id)) { |
|
394 | + Security::clear_token(); |
|
395 | + $tok = Security::get_token(); |
|
396 | + if (!empty($user_id)) { |
|
397 | 397 | if (!empty($picture['name'])) { |
398 | 398 | $picture_uri = UserManager::update_user_picture( |
399 | 399 | $user_id, |
@@ -420,37 +420,37 @@ discard block |
||
420 | 420 | null, |
421 | 421 | $language |
422 | 422 | ); |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | 425 | $extraFieldValues = new ExtraFieldValue('user'); |
426 | 426 | $user['item_id'] = $user_id; |
427 | 427 | $extraFieldValues->saveFieldValues($user); |
428 | - $message = get_lang('UserAdded'); |
|
429 | - } |
|
428 | + $message = get_lang('UserAdded'); |
|
429 | + } |
|
430 | 430 | |
431 | - if (isset($user['submit_plus'])) { |
|
432 | - //we want to add more. Prepare report message and redirect to the same page (to clean the form) |
|
431 | + if (isset($user['submit_plus'])) { |
|
432 | + //we want to add more. Prepare report message and redirect to the same page (to clean the form) |
|
433 | 433 | Display::addFlash(Display::return_message($message)); |
434 | - header('Location: user_add.php?sec_token='.$tok); |
|
435 | - exit; |
|
436 | - } else { |
|
437 | - $tok = Security::get_token(); |
|
434 | + header('Location: user_add.php?sec_token='.$tok); |
|
435 | + exit; |
|
436 | + } else { |
|
437 | + $tok = Security::get_token(); |
|
438 | 438 | Display::addFlash(Display::return_message($message)); |
439 | - header('Location: user_list.php?sec_token='.$tok); |
|
440 | - exit; |
|
441 | - } |
|
442 | - } |
|
439 | + header('Location: user_list.php?sec_token='.$tok); |
|
440 | + exit; |
|
441 | + } |
|
442 | + } |
|
443 | 443 | } else { |
444 | - if (isset($_POST['submit'])) { |
|
445 | - Security::clear_token(); |
|
446 | - } |
|
447 | - $token = Security::get_token(); |
|
448 | - $form->addElement('hidden', 'sec_token'); |
|
449 | - $form->setConstants(array('sec_token' => $token)); |
|
444 | + if (isset($_POST['submit'])) { |
|
445 | + Security::clear_token(); |
|
446 | + } |
|
447 | + $token = Security::get_token(); |
|
448 | + $form->addElement('hidden', 'sec_token'); |
|
449 | + $form->setConstants(array('sec_token' => $token)); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | if (!empty($message)){ |
453 | - $message = Display::return_message(stripslashes($message)); |
|
453 | + $message = Display::return_message(stripslashes($message)); |
|
454 | 454 | } |
455 | 455 | $content = $form->returnForm(); |
456 | 456 |
@@ -11,232 +11,232 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class WSUser extends WS { |
13 | 13 | |
14 | - /** |
|
15 | - * Enables or disables a user |
|
16 | - * |
|
17 | - * @param string User id field name |
|
18 | - * @param string User id value |
|
19 | - * @param int Set to 1 to enable and to 0 to disable |
|
20 | - */ |
|
21 | - protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
22 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | - if($user_id instanceof WSError) { |
|
24 | - return $user_id; |
|
25 | - } else { |
|
26 | - if($state == 0) { |
|
27 | - UserManager::disable($user_id); |
|
28 | - } else if($state == 1) { |
|
29 | - UserManager::enable($user_id); |
|
30 | - } |
|
31 | - } |
|
32 | - } |
|
14 | + /** |
|
15 | + * Enables or disables a user |
|
16 | + * |
|
17 | + * @param string User id field name |
|
18 | + * @param string User id value |
|
19 | + * @param int Set to 1 to enable and to 0 to disable |
|
20 | + */ |
|
21 | + protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) { |
|
22 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | + if($user_id instanceof WSError) { |
|
24 | + return $user_id; |
|
25 | + } else { |
|
26 | + if($state == 0) { |
|
27 | + UserManager::disable($user_id); |
|
28 | + } else if($state == 1) { |
|
29 | + UserManager::enable($user_id); |
|
30 | + } |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Enables or disables multiple users |
|
36 | - * |
|
37 | - * @param array Users |
|
38 | - * @param int Set to 1 to enable and to 0 to disable |
|
39 | - * @return array Array of results |
|
40 | - */ |
|
41 | - protected function changeUsersActiveState($users, $state) { |
|
42 | - $results = array(); |
|
43 | - foreach($users as $user) { |
|
44 | - $result_tmp = array(); |
|
45 | - $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
46 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
47 | - if($result_op instanceof WSError) { |
|
48 | - // Return the error in the results |
|
49 | - $result_tmp['result'] = $result_op->toArray(); |
|
50 | - } else { |
|
51 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
52 | - } |
|
53 | - $results[] = $result_tmp; |
|
54 | - } |
|
55 | - return $results; |
|
56 | - } |
|
34 | + /** |
|
35 | + * Enables or disables multiple users |
|
36 | + * |
|
37 | + * @param array Users |
|
38 | + * @param int Set to 1 to enable and to 0 to disable |
|
39 | + * @return array Array of results |
|
40 | + */ |
|
41 | + protected function changeUsersActiveState($users, $state) { |
|
42 | + $results = array(); |
|
43 | + foreach($users as $user) { |
|
44 | + $result_tmp = array(); |
|
45 | + $result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state); |
|
46 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
47 | + if($result_op instanceof WSError) { |
|
48 | + // Return the error in the results |
|
49 | + $result_tmp['result'] = $result_op->toArray(); |
|
50 | + } else { |
|
51 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
52 | + } |
|
53 | + $results[] = $result_tmp; |
|
54 | + } |
|
55 | + return $results; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Disables a user |
|
60 | - * |
|
61 | - * @param string API secret key |
|
62 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
63 | - * @param string User id value |
|
64 | - */ |
|
65 | - public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
66 | - $verifKey = $this->verifyKey($secret_key); |
|
67 | - if($verifKey instanceof WSError) { |
|
68 | - // Let the implementation handle it |
|
69 | - $this->handleError($verifKey); |
|
70 | - } else { |
|
71 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
72 | - if($result instanceof WSError) { |
|
73 | - $this->handleError($result); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
58 | + /** |
|
59 | + * Disables a user |
|
60 | + * |
|
61 | + * @param string API secret key |
|
62 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
63 | + * @param string User id value |
|
64 | + */ |
|
65 | + public function DisableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
66 | + $verifKey = $this->verifyKey($secret_key); |
|
67 | + if($verifKey instanceof WSError) { |
|
68 | + // Let the implementation handle it |
|
69 | + $this->handleError($verifKey); |
|
70 | + } else { |
|
71 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0); |
|
72 | + if($result instanceof WSError) { |
|
73 | + $this->handleError($result); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Disables multiple users |
|
80 | - * |
|
81 | - * @param string API secret key |
|
82 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
83 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
84 | - * than 0, an error occured |
|
85 | - */ |
|
86 | - public function DisableUsers($secret_key, $users) { |
|
87 | - $verifKey = $this->verifyKey($secret_key); |
|
88 | - if($verifKey instanceof WSError) { |
|
89 | - // Let the implementation handle it |
|
90 | - $this->handleError($verifKey); |
|
91 | - } else { |
|
92 | - return $this->changeUsersActiveState($users, 0); |
|
93 | - } |
|
94 | - } |
|
78 | + /** |
|
79 | + * Disables multiple users |
|
80 | + * |
|
81 | + * @param string API secret key |
|
82 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
83 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
84 | + * than 0, an error occured |
|
85 | + */ |
|
86 | + public function DisableUsers($secret_key, $users) { |
|
87 | + $verifKey = $this->verifyKey($secret_key); |
|
88 | + if($verifKey instanceof WSError) { |
|
89 | + // Let the implementation handle it |
|
90 | + $this->handleError($verifKey); |
|
91 | + } else { |
|
92 | + return $this->changeUsersActiveState($users, 0); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Enables a user |
|
98 | - * |
|
99 | - * @param string API secret key |
|
100 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
101 | - * @param string User id value |
|
102 | - */ |
|
103 | - public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
104 | - $verifKey = $this->verifyKey($secret_key); |
|
105 | - if($verifKey instanceof WSError) { |
|
106 | - $this->handleError($verifKey); |
|
107 | - } else { |
|
108 | - $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
109 | - if($result instanceof WSError) { |
|
110 | - $this->handleError($result); |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
96 | + /** |
|
97 | + * Enables a user |
|
98 | + * |
|
99 | + * @param string API secret key |
|
100 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
101 | + * @param string User id value |
|
102 | + */ |
|
103 | + public function EnableUser($secret_key, $user_id_field_name, $user_id_value) { |
|
104 | + $verifKey = $this->verifyKey($secret_key); |
|
105 | + if($verifKey instanceof WSError) { |
|
106 | + $this->handleError($verifKey); |
|
107 | + } else { |
|
108 | + $result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1); |
|
109 | + if($result instanceof WSError) { |
|
110 | + $this->handleError($result); |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Enables multiple users |
|
117 | - * |
|
118 | - * @param string API secret key |
|
119 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
120 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
121 | - * than 0, an error occured |
|
122 | - */ |
|
123 | - public function EnableUsers($secret_key, $users) { |
|
124 | - $verifKey = $this->verifyKey($secret_key); |
|
125 | - if($verifKey instanceof WSError) { |
|
126 | - // Let the implementation handle it |
|
127 | - $this->handleError($verifKey); |
|
128 | - } else { |
|
129 | - return $this->changeUsersActiveState($users, 1); |
|
130 | - } |
|
131 | - } |
|
115 | + /** |
|
116 | + * Enables multiple users |
|
117 | + * |
|
118 | + * @param string API secret key |
|
119 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
120 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
121 | + * than 0, an error occured |
|
122 | + */ |
|
123 | + public function EnableUsers($secret_key, $users) { |
|
124 | + $verifKey = $this->verifyKey($secret_key); |
|
125 | + if($verifKey instanceof WSError) { |
|
126 | + // Let the implementation handle it |
|
127 | + $this->handleError($verifKey); |
|
128 | + } else { |
|
129 | + return $this->changeUsersActiveState($users, 1); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Deletes a user (helper method) |
|
135 | - * |
|
136 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
137 | - * @param string User id value |
|
138 | - * @return mixed True if user was successfully deleted, WSError otherwise |
|
139 | - */ |
|
140 | - protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
141 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
142 | - if($user_id instanceof WSError) { |
|
143 | - return $user_id; |
|
144 | - } else { |
|
145 | - if(!UserManager::delete_user($user_id)) { |
|
146 | - return new WSError(101, "There was a problem while deleting this user"); |
|
147 | - } else { |
|
148 | - return true; |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
133 | + /** |
|
134 | + * Deletes a user (helper method) |
|
135 | + * |
|
136 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
137 | + * @param string User id value |
|
138 | + * @return mixed True if user was successfully deleted, WSError otherwise |
|
139 | + */ |
|
140 | + protected function deleteUserHelper($user_id_field_name, $user_id_value) { |
|
141 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
142 | + if($user_id instanceof WSError) { |
|
143 | + return $user_id; |
|
144 | + } else { |
|
145 | + if(!UserManager::delete_user($user_id)) { |
|
146 | + return new WSError(101, "There was a problem while deleting this user"); |
|
147 | + } else { |
|
148 | + return true; |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Deletes a user |
|
155 | - * |
|
156 | - * @param string API secret key |
|
157 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
158 | - * @param string User id value |
|
159 | - */ |
|
160 | - public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
161 | - $verifKey = $this->verifyKey($secret_key); |
|
162 | - if($verifKey instanceof WSError) { |
|
163 | - $this->handleError($verifKey); |
|
164 | - } else { |
|
165 | - $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
166 | - if($result instanceof WSError) { |
|
167 | - $this->handleError($result); |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
153 | + /** |
|
154 | + * Deletes a user |
|
155 | + * |
|
156 | + * @param string API secret key |
|
157 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
158 | + * @param string User id value |
|
159 | + */ |
|
160 | + public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) { |
|
161 | + $verifKey = $this->verifyKey($secret_key); |
|
162 | + if($verifKey instanceof WSError) { |
|
163 | + $this->handleError($verifKey); |
|
164 | + } else { |
|
165 | + $result = $this->deleteUserHelper($user_id_field_name, $user_id_value); |
|
166 | + if($result instanceof WSError) { |
|
167 | + $this->handleError($result); |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Deletes multiple users |
|
174 | - * |
|
175 | - * @param string API secret key |
|
176 | - * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
177 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
178 | - * than 0, an error occured |
|
179 | - */ |
|
180 | - public function DeleteUsers($secret_key, $users) { |
|
181 | - $verifKey = $this->verifyKey($secret_key); |
|
182 | - if($verifKey instanceof WSError) { |
|
183 | - $this->handleError($verifKey); |
|
184 | - } else { |
|
185 | - $results = array(); |
|
186 | - foreach($users as $user) { |
|
187 | - $result_tmp = array(); |
|
188 | - $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
189 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
190 | - if($result_op instanceof WSError) { |
|
191 | - // Return the error in the results |
|
192 | - $result_tmp['result'] = $result_op->toArray(); |
|
193 | - } else { |
|
194 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
195 | - } |
|
196 | - $results[] = $result_tmp; |
|
197 | - } |
|
198 | - return $results; |
|
199 | - } |
|
200 | - } |
|
172 | + /** |
|
173 | + * Deletes multiple users |
|
174 | + * |
|
175 | + * @param string API secret key |
|
176 | + * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value') |
|
177 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
178 | + * than 0, an error occured |
|
179 | + */ |
|
180 | + public function DeleteUsers($secret_key, $users) { |
|
181 | + $verifKey = $this->verifyKey($secret_key); |
|
182 | + if($verifKey instanceof WSError) { |
|
183 | + $this->handleError($verifKey); |
|
184 | + } else { |
|
185 | + $results = array(); |
|
186 | + foreach($users as $user) { |
|
187 | + $result_tmp = array(); |
|
188 | + $result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']); |
|
189 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
190 | + if($result_op instanceof WSError) { |
|
191 | + // Return the error in the results |
|
192 | + $result_tmp['result'] = $result_op->toArray(); |
|
193 | + } else { |
|
194 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
195 | + } |
|
196 | + $results[] = $result_tmp; |
|
197 | + } |
|
198 | + return $results; |
|
199 | + } |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Creates a user (helper method) |
|
204 | - * |
|
205 | - * @param string User first name |
|
206 | - * @param string User last name |
|
207 | - * @param int User status |
|
208 | - * @param string Login name |
|
209 | - * @param string Password (encrypted or not) |
|
210 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
211 | - * to include the salt in the extra fields if you are encrypting the password |
|
212 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
213 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
214 | - * @param int Visibility. |
|
215 | - * @param string User email. |
|
216 | - * @param string Language. |
|
217 | - * @param string Phone. |
|
218 | - * @param string Expiration date |
|
219 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
220 | - * @return mixed New user id generated by the system, WSError otherwise |
|
221 | - */ |
|
222 | - protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
202 | + /** |
|
203 | + * Creates a user (helper method) |
|
204 | + * |
|
205 | + * @param string User first name |
|
206 | + * @param string User last name |
|
207 | + * @param int User status |
|
208 | + * @param string Login name |
|
209 | + * @param string Password (encrypted or not) |
|
210 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
211 | + * to include the salt in the extra fields if you are encrypting the password |
|
212 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
213 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
214 | + * @param int Visibility. |
|
215 | + * @param string User email. |
|
216 | + * @param string Language. |
|
217 | + * @param string Phone. |
|
218 | + * @param string Expiration date |
|
219 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). |
|
220 | + * @return mixed New user id generated by the system, WSError otherwise |
|
221 | + */ |
|
222 | + protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) { |
|
223 | 223 | |
224 | - // Add the original user id field name and value to the extra fields if needed |
|
225 | - $extras_associative = array(); |
|
226 | - if($user_id_field_name != "chamilo_user_id") { |
|
227 | - $extras_associative[$user_id_field_name] = $user_id_value; |
|
228 | - } |
|
224 | + // Add the original user id field name and value to the extra fields if needed |
|
225 | + $extras_associative = array(); |
|
226 | + if($user_id_field_name != "chamilo_user_id") { |
|
227 | + $extras_associative[$user_id_field_name] = $user_id_value; |
|
228 | + } |
|
229 | 229 | if (!empty($extras)) { |
230 | 230 | foreach($extras as $extra) { |
231 | 231 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
232 | 232 | } |
233 | 233 | } |
234 | - $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
235 | - if (!$result) { |
|
234 | + $result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method); |
|
235 | + if (!$result) { |
|
236 | 236 | |
237 | - return new WSError(104, 'There was an error creating the user'); |
|
237 | + return new WSError(104, 'There was an error creating the user'); |
|
238 | 238 | |
239 | - /*$failure = $api_failureList[0]; |
|
239 | + /*$failure = $api_failureList[0]; |
|
240 | 240 | if($failure == 'login-pass already taken') { |
241 | 241 | return new WSError(102, 'This username is already taken'); |
242 | 242 | } else if($failure == 'encrypt_method invalid') { |
@@ -244,227 +244,227 @@ discard block |
||
244 | 244 | } else { |
245 | 245 | return new WSError(104, 'There was an error creating the user'); |
246 | 246 | }*/ |
247 | - } else { |
|
248 | - return $result; |
|
249 | - } |
|
250 | - } |
|
247 | + } else { |
|
248 | + return $result; |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * Creates a user |
|
254 | - * |
|
255 | - * @param string API secret key |
|
256 | - * @param string User first name |
|
257 | - * @param string User last name |
|
258 | - * @param int User status |
|
259 | - * @param string Login name |
|
260 | - * @param string Password (encrypted or not) |
|
261 | - * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
262 | - * to include the salt in the extra fields if you are encrypting the password |
|
263 | - * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
264 | - * @param string User id value. Leave blank if you are using the internal user_id |
|
265 | - * @param int Visibility. Set by default to 1 |
|
266 | - * @param string User email. Set by default to an empty string |
|
267 | - * @param string Language. Set by default to english |
|
268 | - * @param string Phone. Set by default to an empty string |
|
269 | - * @param string Expiration date. Set to null by default |
|
270 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
271 | - * @return int New user id generated by the system |
|
272 | - */ |
|
273 | - public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
274 | - // First, verify the secret key |
|
275 | - $verifKey = $this->verifyKey($secret_key); |
|
276 | - if($verifKey instanceof WSError) { |
|
277 | - $this->handleError($verifKey); |
|
278 | - } else { |
|
279 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
280 | - if($result instanceof WSError) { |
|
281 | - $this->handleError($result); |
|
282 | - } else { |
|
283 | - return $result; |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
252 | + /** |
|
253 | + * Creates a user |
|
254 | + * |
|
255 | + * @param string API secret key |
|
256 | + * @param string User first name |
|
257 | + * @param string User last name |
|
258 | + * @param int User status |
|
259 | + * @param string Login name |
|
260 | + * @param string Password (encrypted or not) |
|
261 | + * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember |
|
262 | + * to include the salt in the extra fields if you are encrypting the password |
|
263 | + * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id |
|
264 | + * @param string User id value. Leave blank if you are using the internal user_id |
|
265 | + * @param int Visibility. Set by default to 1 |
|
266 | + * @param string User email. Set by default to an empty string |
|
267 | + * @param string Language. Set by default to english |
|
268 | + * @param string Phone. Set by default to an empty string |
|
269 | + * @param string Expiration date. Set to null by default |
|
270 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default |
|
271 | + * @return int New user id generated by the system |
|
272 | + */ |
|
273 | + public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) { |
|
274 | + // First, verify the secret key |
|
275 | + $verifKey = $this->verifyKey($secret_key); |
|
276 | + if($verifKey instanceof WSError) { |
|
277 | + $this->handleError($verifKey); |
|
278 | + } else { |
|
279 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
280 | + if($result instanceof WSError) { |
|
281 | + $this->handleError($result); |
|
282 | + } else { |
|
283 | + return $result; |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
289 | - * Creates multiple users |
|
290 | - * |
|
291 | - * @param string API secret key |
|
292 | - * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
293 | - * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
294 | - */ |
|
295 | - public function CreateUsers($secret_key, $users) { |
|
296 | - $verifKey = $this->verifyKey($secret_key); |
|
297 | - if($verifKey instanceof WSError) { |
|
298 | - $this->handleError($verifKey); |
|
299 | - } else { |
|
300 | - $results = array(); |
|
301 | - foreach($users as $user) { |
|
302 | - $result_tmp = array(); |
|
288 | + /** |
|
289 | + * Creates multiple users |
|
290 | + * |
|
291 | + * @param string API secret key |
|
292 | + * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method |
|
293 | + * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful')) |
|
294 | + */ |
|
295 | + public function CreateUsers($secret_key, $users) { |
|
296 | + $verifKey = $this->verifyKey($secret_key); |
|
297 | + if($verifKey instanceof WSError) { |
|
298 | + $this->handleError($verifKey); |
|
299 | + } else { |
|
300 | + $results = array(); |
|
301 | + foreach($users as $user) { |
|
302 | + $result_tmp = array(); |
|
303 | 303 | // re-initialize variables just in case |
304 | 304 | $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null; |
305 | - extract($user); |
|
306 | - $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
307 | - if($result instanceof WSError) { |
|
308 | - $result_tmp['result'] = $result->toArray(); |
|
309 | - $result_tmp['user_id_value'] = $user_id_value; |
|
310 | - $result_tmp['user_id_generated'] = 0; |
|
311 | - } else { |
|
312 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
313 | - $result_tmp['user_id_value'] = $user_id_value; |
|
314 | - $result_tmp['user_id_generated'] = $result; |
|
315 | - } |
|
316 | - $results[] = $result_tmp; |
|
317 | - } |
|
318 | - return $results; |
|
319 | - } |
|
320 | - } |
|
305 | + extract($user); |
|
306 | + $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras); |
|
307 | + if($result instanceof WSError) { |
|
308 | + $result_tmp['result'] = $result->toArray(); |
|
309 | + $result_tmp['user_id_value'] = $user_id_value; |
|
310 | + $result_tmp['user_id_generated'] = 0; |
|
311 | + } else { |
|
312 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
313 | + $result_tmp['user_id_value'] = $user_id_value; |
|
314 | + $result_tmp['user_id_generated'] = $result; |
|
315 | + } |
|
316 | + $results[] = $result_tmp; |
|
317 | + } |
|
318 | + return $results; |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | - /** |
|
323 | - * Edits user info (helper method) |
|
324 | - * |
|
325 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
326 | - * @param string User id value |
|
327 | - * @param string First name |
|
328 | - * @param string Last name |
|
329 | - * @param int User status |
|
330 | - * @param string Login name |
|
331 | - * @param string Password. Leave blank if you don't want to update it |
|
332 | - * @param string Encrypt method |
|
333 | - * @param string User email |
|
334 | - * @param string Language. Set by default to english |
|
335 | - * @param string Phone. Set by default to an empty string |
|
336 | - * @param string Expiration date. Set to null by default |
|
337 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
338 | - * @return mixed True if user was successfully updated, WSError otherwise |
|
339 | - */ |
|
340 | - protected function editUserHelper( |
|
341 | - $user_id_field_name, |
|
342 | - $user_id_value, |
|
343 | - $firstname, |
|
344 | - $lastname, |
|
345 | - $status, |
|
346 | - $loginname, |
|
347 | - $password, |
|
348 | - $encrypt_method, |
|
349 | - $email, |
|
350 | - $language, |
|
351 | - $phone, |
|
352 | - $expiration_date, |
|
353 | - $extras |
|
354 | - ) { |
|
355 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
356 | - if($user_id instanceof WSError) { |
|
357 | - return $user_id; |
|
358 | - } else { |
|
359 | - if($password == '') { |
|
360 | - $password = null; |
|
361 | - } |
|
362 | - $user_info = api_get_user_info($user_id); |
|
363 | - if (count($extras) == 0) { |
|
364 | - $extras = null; |
|
365 | - } |
|
322 | + /** |
|
323 | + * Edits user info (helper method) |
|
324 | + * |
|
325 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
326 | + * @param string User id value |
|
327 | + * @param string First name |
|
328 | + * @param string Last name |
|
329 | + * @param int User status |
|
330 | + * @param string Login name |
|
331 | + * @param string Password. Leave blank if you don't want to update it |
|
332 | + * @param string Encrypt method |
|
333 | + * @param string User email |
|
334 | + * @param string Language. Set by default to english |
|
335 | + * @param string Phone. Set by default to an empty string |
|
336 | + * @param string Expiration date. Set to null by default |
|
337 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
338 | + * @return mixed True if user was successfully updated, WSError otherwise |
|
339 | + */ |
|
340 | + protected function editUserHelper( |
|
341 | + $user_id_field_name, |
|
342 | + $user_id_value, |
|
343 | + $firstname, |
|
344 | + $lastname, |
|
345 | + $status, |
|
346 | + $loginname, |
|
347 | + $password, |
|
348 | + $encrypt_method, |
|
349 | + $email, |
|
350 | + $language, |
|
351 | + $phone, |
|
352 | + $expiration_date, |
|
353 | + $extras |
|
354 | + ) { |
|
355 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
356 | + if($user_id instanceof WSError) { |
|
357 | + return $user_id; |
|
358 | + } else { |
|
359 | + if($password == '') { |
|
360 | + $password = null; |
|
361 | + } |
|
362 | + $user_info = api_get_user_info($user_id); |
|
363 | + if (count($extras) == 0) { |
|
364 | + $extras = null; |
|
365 | + } |
|
366 | 366 | |
367 | - $result = UserManager::update_user( |
|
368 | - $user_id, |
|
369 | - $firstname, |
|
370 | - $lastname, |
|
371 | - $loginname, |
|
372 | - $password, |
|
373 | - PLATFORM_AUTH_SOURCE, |
|
374 | - $email, |
|
375 | - $status, |
|
376 | - '', |
|
377 | - $phone, |
|
378 | - $user_info['picture_uri'], |
|
379 | - $expiration_date, |
|
380 | - $user_info['active'], |
|
381 | - null, |
|
382 | - $user_info['hr_dept_id'], |
|
383 | - $extras, |
|
384 | - $encrypt_method |
|
385 | - ); |
|
386 | - if (!$result) { |
|
387 | - /*if($failure == 'encrypt_method invalid') { |
|
367 | + $result = UserManager::update_user( |
|
368 | + $user_id, |
|
369 | + $firstname, |
|
370 | + $lastname, |
|
371 | + $loginname, |
|
372 | + $password, |
|
373 | + PLATFORM_AUTH_SOURCE, |
|
374 | + $email, |
|
375 | + $status, |
|
376 | + '', |
|
377 | + $phone, |
|
378 | + $user_info['picture_uri'], |
|
379 | + $expiration_date, |
|
380 | + $user_info['active'], |
|
381 | + null, |
|
382 | + $user_info['hr_dept_id'], |
|
383 | + $extras, |
|
384 | + $encrypt_method |
|
385 | + ); |
|
386 | + if (!$result) { |
|
387 | + /*if($failure == 'encrypt_method invalid') { |
|
388 | 388 | return new WSError(103, 'The encryption of the password is invalid'); |
389 | 389 | } else { |
390 | 390 | return new WSError(105, 'There was an error updating the user'); |
391 | 391 | }*/ |
392 | - return new WSError(105, 'There was an error updating the user'); |
|
393 | - } else { |
|
394 | - return $result; |
|
395 | - } |
|
396 | - } |
|
397 | - } |
|
392 | + return new WSError(105, 'There was an error updating the user'); |
|
393 | + } else { |
|
394 | + return $result; |
|
395 | + } |
|
396 | + } |
|
397 | + } |
|
398 | 398 | |
399 | - /** |
|
400 | - * Edits user info |
|
401 | - * |
|
402 | - * @param string API secret key |
|
403 | - * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
404 | - * @param string User id value |
|
405 | - * @param string First name |
|
406 | - * @param string Last name |
|
407 | - * @param int User status |
|
408 | - * @param string Login name |
|
409 | - * @param string Password. Leave blank if you don't want to update it |
|
410 | - * @param string Encrypt method |
|
411 | - * @param string User email |
|
412 | - * @param string Language. Set by default to english |
|
413 | - * @param string Phone. Set by default to an empty string |
|
414 | - * @param string Expiration date. Set to null by default |
|
415 | - * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
416 | - */ |
|
417 | - public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
418 | - // First, verify the secret key |
|
419 | - $verifKey = $this->verifyKey($secret_key); |
|
420 | - if($verifKey instanceof WSError) { |
|
421 | - $this->handleError($verifKey); |
|
422 | - } else { |
|
399 | + /** |
|
400 | + * Edits user info |
|
401 | + * |
|
402 | + * @param string API secret key |
|
403 | + * @param string User id field name. Use "chamilo_user_id" in order to use internal system id |
|
404 | + * @param string User id value |
|
405 | + * @param string First name |
|
406 | + * @param string Last name |
|
407 | + * @param int User status |
|
408 | + * @param string Login name |
|
409 | + * @param string Password. Leave blank if you don't want to update it |
|
410 | + * @param string Encrypt method |
|
411 | + * @param string User email |
|
412 | + * @param string Language. Set by default to english |
|
413 | + * @param string Phone. Set by default to an empty string |
|
414 | + * @param string Expiration date. Set to null by default |
|
415 | + * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update |
|
416 | + */ |
|
417 | + public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { |
|
418 | + // First, verify the secret key |
|
419 | + $verifKey = $this->verifyKey($secret_key); |
|
420 | + if($verifKey instanceof WSError) { |
|
421 | + $this->handleError($verifKey); |
|
422 | + } else { |
|
423 | 423 | |
424 | - $extras_associative = array(); |
|
425 | - if (!empty($extras)) { |
|
426 | - foreach($extras as $extra) { |
|
427 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
428 | - } |
|
429 | - } |
|
424 | + $extras_associative = array(); |
|
425 | + if (!empty($extras)) { |
|
426 | + foreach($extras as $extra) { |
|
427 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
428 | + } |
|
429 | + } |
|
430 | 430 | |
431 | - $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
432 | - if($result instanceof WSError) { |
|
433 | - $this->handleError($result); |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
431 | + $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative); |
|
432 | + if($result instanceof WSError) { |
|
433 | + $this->handleError($result); |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | 437 | |
438 | - /** |
|
439 | - * Edits multiple users |
|
440 | - * |
|
441 | - * @param string API secret key |
|
442 | - * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
443 | - * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
444 | - * than 0, an error occured |
|
445 | - */ |
|
446 | - public function EditUsers($secret_key, $users) { |
|
447 | - $verifKey = $this->verifyKey($secret_key); |
|
448 | - if($verifKey instanceof WSError) { |
|
449 | - $this->handleError($verifKey); |
|
450 | - } else { |
|
451 | - $results = array(); |
|
452 | - foreach($users as $user) { |
|
453 | - $result_tmp = array(); |
|
438 | + /** |
|
439 | + * Edits multiple users |
|
440 | + * |
|
441 | + * @param string API secret key |
|
442 | + * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method |
|
443 | + * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different |
|
444 | + * than 0, an error occured |
|
445 | + */ |
|
446 | + public function EditUsers($secret_key, $users) { |
|
447 | + $verifKey = $this->verifyKey($secret_key); |
|
448 | + if($verifKey instanceof WSError) { |
|
449 | + $this->handleError($verifKey); |
|
450 | + } else { |
|
451 | + $results = array(); |
|
452 | + foreach($users as $user) { |
|
453 | + $result_tmp = array(); |
|
454 | 454 | // re-initialize variables just in case |
455 | 455 | $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null; |
456 | - extract($user); |
|
457 | - $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
458 | - $result_tmp['user_id_value'] = $user['user_id_value']; |
|
459 | - if($result_op instanceof WSError) { |
|
460 | - // Return the error in the results |
|
461 | - $result_tmp['result'] = $result_op->toArray(); |
|
462 | - } else { |
|
463 | - $result_tmp['result'] = $this->getSuccessfulResult(); |
|
464 | - } |
|
465 | - $results[] = $result_tmp; |
|
466 | - } |
|
467 | - return $results; |
|
468 | - } |
|
469 | - } |
|
456 | + extract($user); |
|
457 | + $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras); |
|
458 | + $result_tmp['user_id_value'] = $user['user_id_value']; |
|
459 | + if($result_op instanceof WSError) { |
|
460 | + // Return the error in the results |
|
461 | + $result_tmp['result'] = $result_op->toArray(); |
|
462 | + } else { |
|
463 | + $result_tmp['result'] = $this->getSuccessfulResult(); |
|
464 | + } |
|
465 | + $results[] = $result_tmp; |
|
466 | + } |
|
467 | + return $results; |
|
468 | + } |
|
469 | + } |
|
470 | 470 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if ($add_type == 'multiple') { |
123 | - $link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'. |
|
123 | + $link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'. |
|
124 | 124 | get_lang('SessionAddTypeUnique').'</a>'; |
125 | - $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
|
125 | + $link_add_type_multiple = get_lang('SessionAddTypeMultiple'); |
|
126 | 126 | } else { |
127 | - $link_add_type_unique = get_lang('SessionAddTypeUnique'); |
|
128 | - $link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'. |
|
127 | + $link_add_type_unique = get_lang('SessionAddTypeUnique'); |
|
128 | + $link_add_type_multiple = '<a href="'.api_get_self().'?add_type=multiple&access_url_id='.$access_url_id.'">'. |
|
129 | 129 | get_lang('SessionAddTypeMultiple').'</a>'; |
130 | 130 | } |
131 | 131 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | <td colspan="3" align="center"> |
224 | 224 | <br /> |
225 | 225 | <?php |
226 | - if(isset($_GET['add'])) |
|
227 | - echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>'; |
|
228 | - else |
|
229 | - echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>'; |
|
230 | - ?> |
|
226 | + if(isset($_GET['add'])) |
|
227 | + echo '<button class="save" onclick="valide()" >'.get_lang('Add').'</button>'; |
|
228 | + else |
|
229 | + echo '<button class="save" onclick="valide()" >'.get_lang('Edit').'</button>'; |
|
230 | + ?> |
|
231 | 231 | </td> |
232 | 232 | </tr> |
233 | 233 | </table> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $xajax = new xajax(); |
13 | 13 | $xajax->registerFunction( |
14 | - array('search_courses', 'Accessurleditcoursestourl', 'search_courses') |
|
14 | + array('search_courses', 'Accessurleditcoursestourl', 'search_courses') |
|
15 | 15 | ); |
16 | 16 | |
17 | 17 | // setting the section (for the tabs) |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | // Access restrictions |
21 | 21 | api_protect_global_admin_script(); |
22 | 22 | if (!api_get_multiple_access_url()) { |
23 | - header('Location: index.php'); |
|
24 | - exit; |
|
23 | + header('Location: index.php'); |
|
24 | + exit; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | // Database Table Definitions |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | |
37 | 37 | $add_type = 'multiple'; |
38 | 38 | if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') { |
39 | - $add_type = Security::remove_XSS($_REQUEST['add_type']); |
|
39 | + $add_type = Security::remove_XSS($_REQUEST['add_type']); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $access_url_id = 1; |
43 | 43 | if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id']!='') { |
44 | - $access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); |
|
44 | + $access_url_id = Security::remove_XSS($_REQUEST['access_url_id']); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $xajax -> processRequests(); |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | <select name="access_url_id" onchange="javascript:send();"> |
163 | 163 | <option value="0">-- <?php echo get_lang('SelectUrl')?> -- </option> |
164 | 164 | <?php |
165 | - $url_selected=''; |
|
166 | - foreach ($url_list as $url_obj) { |
|
167 | - $checked = ''; |
|
168 | - if (!empty($access_url_id)) { |
|
169 | - if ($url_obj[0]==$access_url_id) { |
|
170 | - $checked = 'selected=true'; |
|
171 | - $url_selected=$url_obj[1]; |
|
172 | - } |
|
173 | - } |
|
174 | - if ($url_obj['active']==1) { |
|
175 | - ?> |
|
165 | + $url_selected=''; |
|
166 | + foreach ($url_list as $url_obj) { |
|
167 | + $checked = ''; |
|
168 | + if (!empty($access_url_id)) { |
|
169 | + if ($url_obj[0]==$access_url_id) { |
|
170 | + $checked = 'selected=true'; |
|
171 | + $url_selected=$url_obj[1]; |
|
172 | + } |
|
173 | + } |
|
174 | + if ($url_obj['active']==1) { |
|
175 | + ?> |
|
176 | 176 | <option <?php echo $checked;?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?></option> |
177 | 177 | <?php |
178 | - } |
|
179 | - } |
|
180 | - ?> |
|
178 | + } |
|
179 | + } |
|
180 | + ?> |
|
181 | 181 | </select> |
182 | 182 | <br /><br /> |
183 | 183 | <input type="hidden" name="form_sent" value="1" /> |
@@ -196,38 +196,38 @@ discard block |
||
196 | 196 | <td align="center"> |
197 | 197 | <div id="content_source"> |
198 | 198 | <?php |
199 | - if($ajax_search) { |
|
200 | - ?> |
|
199 | + if($ajax_search) { |
|
200 | + ?> |
|
201 | 201 | <input type="text" id="course_to_add" onkeyup="xajax_search_courses(this.value,document.formulaire.access_url_id.options[document.formulaire.access_url_id.selectedIndex].value)" /> |
202 | 202 | <div id="ajax_list_courses"></div> |
203 | 203 | <?php |
204 | - } else { |
|
205 | - ?> |
|
204 | + } else { |
|
205 | + ?> |
|
206 | 206 | <select id="origin_users" name="no_course_list[]" multiple="multiple" size="15" style="width:380px;"> |
207 | 207 | <?php |
208 | - foreach($no_course_list as $no_course) { |
|
209 | - ?> |
|
208 | + foreach($no_course_list as $no_course) { |
|
209 | + ?> |
|
210 | 210 | <option value="<?php echo $no_course['id']; ?>"><?php echo $no_course['title'].' ('.$no_course['code'].')'; ?></option> |
211 | 211 | <?php |
212 | - } |
|
213 | - unset($no_course_list); |
|
214 | - ?> |
|
212 | + } |
|
213 | + unset($no_course_list); |
|
214 | + ?> |
|
215 | 215 | </select> |
216 | 216 | <?php |
217 | - } |
|
218 | - ?> |
|
217 | + } |
|
218 | + ?> |
|
219 | 219 | </div> |
220 | 220 | </td> |
221 | 221 | <td width="10%" valign="middle" align="center"> |
222 | 222 | <?php |
223 | - if($ajax_search) { |
|
224 | - ?> |
|
223 | + if($ajax_search) { |
|
224 | + ?> |
|
225 | 225 | <button class="btn btn-default" type="button" onclick="remove_item(document.getElementById('destination_users'))" > |
226 | 226 | <em class="fa fa-arrow-left"></em> |
227 | 227 | </button> |
228 | 228 | <?php |
229 | - } else { |
|
230 | - ?> |
|
229 | + } else { |
|
230 | + ?> |
|
231 | 231 | <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" > |
232 | 232 | <em class="fa fa-arrow-right"></em> |
233 | 233 | </button> |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | <em class="fa fa-arrow-left"></em> |
237 | 237 | </button> |
238 | 238 | <?php |
239 | - } |
|
240 | - ?> |
|
239 | + } |
|
240 | + ?> |
|
241 | 241 | <br /><br /><br /><br /><br /><br /> |
242 | 242 | </td> |
243 | 243 | <td align="center"> |
244 | 244 | <select id="destination_users" name="course_list[]" multiple="multiple" size="15" style="width:380px;"> |
245 | 245 | <?php |
246 | - foreach($course_list as $course) { |
|
247 | - $courseInfo = api_get_course_info_by_id($course['id']); |
|
248 | - ?> |
|
246 | + foreach($course_list as $course) { |
|
247 | + $courseInfo = api_get_course_info_by_id($course['id']); |
|
248 | + ?> |
|
249 | 249 | <option value="<?php echo $course['id']; ?>"><?php echo $course['title'].' ('.$courseInfo['code'].')'; ?></option> |
250 | 250 | <?php |
251 | - } |
|
252 | - unset($course_list); |
|
253 | - ?> |
|
251 | + } |
|
252 | + unset($course_list); |
|
253 | + ?> |
|
254 | 254 | |
255 | 255 | </select></td> |
256 | 256 | </tr> |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | <td colspan="3" align="center"> |
259 | 259 | <br /> |
260 | 260 | <?php |
261 | - if(isset($_GET['add'])) |
|
262 | - echo '<button class="btn btn-default" onclick="valide()" >'.get_lang('AddCoursesToURL').'</button>'; |
|
263 | - else |
|
264 | - echo '<button class="btn btn-default" onclick="valide()" >'.get_lang('EditCoursesToURL').'</button>'; |
|
265 | - ?> |
|
261 | + if(isset($_GET['add'])) |
|
262 | + echo '<button class="btn btn-default" onclick="valide()" >'.get_lang('AddCoursesToURL').'</button>'; |
|
263 | + else |
|
264 | + echo '<button class="btn btn-default" onclick="valide()" >'.get_lang('EditCoursesToURL').'</button>'; |
|
265 | + ?> |
|
266 | 266 | </td> |
267 | 267 | </tr> |
268 | 268 | </table> |