@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | // storing all the permission for a given role when the checkbox approach is used |
19 | 19 | if ($_POST['StoreRolePermissions']) |
20 | 20 | { |
21 | - if (!empty($_POST['role_name'])) |
|
22 | - { |
|
23 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
24 | - $sql="INSERT INTO $table_role (role_name, role_comment, default_role) |
|
21 | + if (!empty($_POST['role_name'])) |
|
22 | + { |
|
23 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
24 | + $sql="INSERT INTO $table_role (role_name, role_comment, default_role) |
|
25 | 25 | VALUES ('".Database::escape_string($_POST['role_name'])."','".Database::escape_string($_POST['role_comment'])."','".Database::escape_string($_POST['default_role'])."')"; |
26 | - $result=Database::query($sql); |
|
27 | - $role_id=Database::insert_id(); |
|
28 | - $result_message=store_permissions('role', $role_id); |
|
29 | - } |
|
30 | - else |
|
31 | - { |
|
32 | - $result_message=get_lang('ErrorPleaseGiveRoleName'); |
|
33 | - } |
|
26 | + $result=Database::query($sql); |
|
27 | + $role_id=Database::insert_id(); |
|
28 | + $result_message=store_permissions('role', $role_id); |
|
29 | + } |
|
30 | + else |
|
31 | + { |
|
32 | + $result_message=get_lang('ErrorPleaseGiveRoleName'); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | // storing a permission for a given role when the image approach is used |
36 | 36 | if (isset($_GET['action']) AND isset($_GET['permission']) AND isset($_GET['tool'])) |
37 | 37 | { |
38 | - if ($_GET['action']=='grant' OR $_GET['action']=='revoke') |
|
39 | - { |
|
40 | - $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
41 | - } |
|
38 | + if ($_GET['action']=='grant' OR $_GET['action']=='revoke') |
|
39 | + { |
|
40 | + $result_message=store_one_permission('role', $_GET['action'], $role_id, $_GET['tool'], $_GET['permission']); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // deleting a role |
45 | 45 | if (isset($_GET['action']) AND isset($_GET['role_id']) AND $_GET['action']=='delete') { |
46 | - //deleting the assignments fo this role: users |
|
47 | - $table=Database::get_course_table(TABLE_ROLE_USER); |
|
48 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | - $result=Database::query($sql); |
|
46 | + //deleting the assignments fo this role: users |
|
47 | + $table=Database::get_course_table(TABLE_ROLE_USER); |
|
48 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
49 | + $result=Database::query($sql); |
|
50 | 50 | |
51 | - // deleting the assignments of this role: groups |
|
52 | - $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | - $result=Database::query($sql); |
|
51 | + // deleting the assignments of this role: groups |
|
52 | + $table=Database::get_course_table(TABLE_ROLE_GROUP); |
|
53 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
54 | + $result=Database::query($sql); |
|
55 | 55 | |
56 | - // deleting the permissions of this role |
|
57 | - $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | - $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | - $result=Database::query($sql); |
|
56 | + // deleting the permissions of this role |
|
57 | + $table=Database::get_course_table(TABLE_ROLE_PERMISSION); |
|
58 | + $sql="DELETE FROM $table WHERE role_id='".intval($_GET['role_id'])."'"; |
|
59 | + $result=Database::query($sql); |
|
60 | 60 | |
61 | - // deleting the role |
|
62 | - $table_role=Database::get_course_table(TABLE_ROLE); |
|
63 | - $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | - $result=Database::query($sql); |
|
65 | - $result_message=get_lang('RoleDeleted'); |
|
61 | + // deleting the role |
|
62 | + $table_role=Database::get_course_table(TABLE_ROLE); |
|
63 | + $sql="DELETE FROM $table_role WHERE role_id='".intval($_GET['role_id'])."'"; |
|
64 | + $result=Database::query($sql); |
|
65 | + $result_message=get_lang('RoleDeleted'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // displaying the return message of the actions |
69 | 69 | if (isset($result_message)) { |
70 | - Display::display_normal_message($result_message); |
|
70 | + Display::display_normal_message($result_message); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // ADDING A NEW ROLE (FORM AND LINK) |
@@ -75,73 +75,73 @@ discard block |
||
75 | 75 | |
76 | 76 | if ($_GET['action']=='add') |
77 | 77 | { |
78 | - echo "<form method=\"post\" action=\"".api_get_self()."\">"; |
|
79 | - echo "\n<table>"; |
|
80 | - echo "\n\t<tr>"; |
|
81 | - echo "\n\t\t<td>"; |
|
82 | - echo get_lang('RoleName'); |
|
83 | - echo "\n\t\t</td>"; |
|
84 | - echo "\n\t\t<td>"; |
|
85 | - echo "\n\t\t\t<input type='text' name='role_name'>"; |
|
86 | - echo "\n\t\t</td>"; |
|
87 | - echo "\n\t</tr>"; |
|
88 | - echo "\n\t<tr>"; |
|
89 | - echo "\n\t\t<td>"; |
|
90 | - echo get_lang('RoleComment'); |
|
91 | - echo "\n\t\t</td>"; |
|
92 | - echo "\n\t\t<td>"; |
|
93 | - echo "\n\t\t\t<textarea name='role_comment'></textarea>"; |
|
94 | - echo "\n\t\t</td>"; |
|
95 | - echo "\n\t</tr>"; |
|
96 | - echo "\n\t<tr>"; |
|
97 | - echo "\n\t\t<td>"; |
|
98 | - echo get_lang('DefaultRole'); |
|
99 | - echo "\n\t\t</td>"; |
|
100 | - echo "\n\t\t<td>"; |
|
101 | - echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">"; |
|
102 | - echo "\n\t\t</td>"; |
|
103 | - echo "\n\t</tr>"; |
|
104 | - echo "\n</table>"; |
|
105 | - echo "<table class=\"data_table\">\n"; |
|
78 | + echo "<form method=\"post\" action=\"".api_get_self()."\">"; |
|
79 | + echo "\n<table>"; |
|
80 | + echo "\n\t<tr>"; |
|
81 | + echo "\n\t\t<td>"; |
|
82 | + echo get_lang('RoleName'); |
|
83 | + echo "\n\t\t</td>"; |
|
84 | + echo "\n\t\t<td>"; |
|
85 | + echo "\n\t\t\t<input type='text' name='role_name'>"; |
|
86 | + echo "\n\t\t</td>"; |
|
87 | + echo "\n\t</tr>"; |
|
88 | + echo "\n\t<tr>"; |
|
89 | + echo "\n\t\t<td>"; |
|
90 | + echo get_lang('RoleComment'); |
|
91 | + echo "\n\t\t</td>"; |
|
92 | + echo "\n\t\t<td>"; |
|
93 | + echo "\n\t\t\t<textarea name='role_comment'></textarea>"; |
|
94 | + echo "\n\t\t</td>"; |
|
95 | + echo "\n\t</tr>"; |
|
96 | + echo "\n\t<tr>"; |
|
97 | + echo "\n\t\t<td>"; |
|
98 | + echo get_lang('DefaultRole'); |
|
99 | + echo "\n\t\t</td>"; |
|
100 | + echo "\n\t\t<td>"; |
|
101 | + echo "\n\t\t\t<input type=\"checkbox\" name=\"default_role\" value=\"1\">"; |
|
102 | + echo "\n\t\t</td>"; |
|
103 | + echo "\n\t</tr>"; |
|
104 | + echo "\n</table>"; |
|
105 | + echo "<table class=\"data_table\">\n"; |
|
106 | 106 | |
107 | - // the header |
|
108 | - if (api_get_setting('permissions')=='limited') |
|
109 | - { |
|
110 | - $header_array=$rights_limited; |
|
111 | - } |
|
112 | - if (api_get_setting('permissions')=='full') |
|
113 | - { |
|
114 | - $header_array=$rights_full; |
|
115 | - } |
|
116 | - echo "\t<tr>\n"; |
|
117 | - echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
118 | - foreach ($header_array as $header_key=>$header_value) |
|
119 | - { |
|
120 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
121 | - } |
|
122 | - echo "\t</tr>\n"; |
|
107 | + // the header |
|
108 | + if (api_get_setting('permissions')=='limited') |
|
109 | + { |
|
110 | + $header_array=$rights_limited; |
|
111 | + } |
|
112 | + if (api_get_setting('permissions')=='full') |
|
113 | + { |
|
114 | + $header_array=$rights_full; |
|
115 | + } |
|
116 | + echo "\t<tr>\n"; |
|
117 | + echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
118 | + foreach ($header_array as $header_key=>$header_value) |
|
119 | + { |
|
120 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
121 | + } |
|
122 | + echo "\t</tr>\n"; |
|
123 | 123 | |
124 | - // the main area with the checkboxes or images |
|
125 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
126 | - { |
|
127 | - echo "\t<tr>\n"; |
|
128 | - echo "\t\t<td>\n"; |
|
129 | - echo get_lang($tool); |
|
130 | - echo "\t\t</td>\n"; |
|
124 | + // the main area with the checkboxes or images |
|
125 | + foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
126 | + { |
|
127 | + echo "\t<tr>\n"; |
|
128 | + echo "\t\t<td>\n"; |
|
129 | + echo get_lang($tool); |
|
130 | + echo "\t\t</td>\n"; |
|
131 | 131 | |
132 | - foreach ($header_array as $key=>$value) |
|
133 | - { |
|
134 | - echo "\t\t<td align='center'>\n"; |
|
135 | - display_checkbox_matrix(array(), $tool, $value); |
|
136 | - echo "\t\t</td>\n"; |
|
137 | - } |
|
138 | - echo "\t</tr>\n"; |
|
139 | - } |
|
132 | + foreach ($header_array as $key=>$value) |
|
133 | + { |
|
134 | + echo "\t\t<td align='center'>\n"; |
|
135 | + display_checkbox_matrix(array(), $tool, $value); |
|
136 | + echo "\t\t</td>\n"; |
|
137 | + } |
|
138 | + echo "\t</tr>\n"; |
|
139 | + } |
|
140 | 140 | |
141 | - echo "</table>\n"; |
|
141 | + echo "</table>\n"; |
|
142 | 142 | |
143 | - echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
144 | - echo "</form>"; |
|
143 | + echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
144 | + echo "</form>"; |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -154,23 +154,23 @@ discard block |
||
154 | 154 | $all_roles=get_all_roles('platform'); |
155 | 155 | foreach ($all_roles as $role) |
156 | 156 | { |
157 | - echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'&scope=platform">'.$role['role_name'].'</a></div>'; |
|
158 | - echo '<div>'.$role['role_comment'].'</div><br />'; |
|
159 | - if ($role['role_id']==$_GET['role_id']) |
|
160 | - { |
|
161 | - $current_role_info=$role; |
|
162 | - } |
|
157 | + echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'&scope=platform">'.$role['role_name'].'</a></div>'; |
|
158 | + echo '<div>'.$role['role_comment'].'</div><br />'; |
|
159 | + if ($role['role_id']==$_GET['role_id']) |
|
160 | + { |
|
161 | + $current_role_info=$role; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | // course roles |
165 | 165 | $all_roles=get_all_roles(); |
166 | 166 | foreach ($all_roles as $role) |
167 | 167 | { |
168 | - echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>'; |
|
169 | - echo '<div>'.$role['role_comment'].'</div><br />'; |
|
170 | - if ($role['role_id']==$_GET['role_id']) |
|
171 | - { |
|
172 | - $current_role_info=$role; |
|
173 | - } |
|
168 | + echo '<div><a href="roles.php?action=view&role_id='.$role['role_id'].'">'.$role['role_name'].'</a><a href="roles.php?action=delete&role_id='.$role['role_id'].'"><img src="../img/delete.gif" /></a></div>'; |
|
169 | + echo '<div>'.$role['role_comment'].'</div><br />'; |
|
170 | + if ($role['role_id']==$_GET['role_id']) |
|
171 | + { |
|
172 | + $current_role_info=$role; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // =================================================== |
@@ -178,83 +178,83 @@ discard block |
||
178 | 178 | // =================================================== |
179 | 179 | if ($_GET['role_id']) |
180 | 180 | { |
181 | - $current_role_permissions=get_permissions('role',$_GET['role_id']); |
|
181 | + $current_role_permissions=get_permissions('role',$_GET['role_id']); |
|
182 | 182 | |
183 | - // --------------------------------------------------- |
|
184 | - // LIMITED OR FULL |
|
185 | - // --------------------------------------------------- |
|
186 | - $current_role_permissions=limited_or_full($current_role_permissions); |
|
187 | - if (api_get_setting('permissions')=='limited') |
|
188 | - { |
|
189 | - $header_array=$rights_limited; |
|
190 | - } |
|
191 | - if (api_get_setting('permissions')=='full') |
|
192 | - { |
|
193 | - $header_array=$rights_full; |
|
194 | - } |
|
195 | - // --------------------------------------------------- |
|
196 | - // DISPLAYING THE MATRIX |
|
197 | - // --------------------------------------------------- |
|
198 | - echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
|
183 | + // --------------------------------------------------- |
|
184 | + // LIMITED OR FULL |
|
185 | + // --------------------------------------------------- |
|
186 | + $current_role_permissions=limited_or_full($current_role_permissions); |
|
187 | + if (api_get_setting('permissions')=='limited') |
|
188 | + { |
|
189 | + $header_array=$rights_limited; |
|
190 | + } |
|
191 | + if (api_get_setting('permissions')=='full') |
|
192 | + { |
|
193 | + $header_array=$rights_full; |
|
194 | + } |
|
195 | + // --------------------------------------------------- |
|
196 | + // DISPLAYING THE MATRIX |
|
197 | + // --------------------------------------------------- |
|
198 | + echo "<form method=\"post\" action=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."\">"; |
|
199 | 199 | |
200 | - // the list of the roles for the user |
|
201 | - echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />'; |
|
202 | - if ($_GET['scope']=='platform') |
|
203 | - { |
|
204 | - echo get_lang('IsPlatformRoleNotEditable').'<br />'; |
|
205 | - } |
|
200 | + // the list of the roles for the user |
|
201 | + echo get_lang('PermissionsOfRole').':'.$current_role_info['role_name'].'<br />'; |
|
202 | + if ($_GET['scope']=='platform') |
|
203 | + { |
|
204 | + echo get_lang('IsPlatformRoleNotEditable').'<br />'; |
|
205 | + } |
|
206 | 206 | |
207 | - echo "<table class=\"data_table\">\n"; |
|
207 | + echo "<table class=\"data_table\">\n"; |
|
208 | 208 | |
209 | - // the header |
|
210 | - echo "\t<tr>\n"; |
|
211 | - echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
212 | - foreach ($header_array as $header_key=>$header_value) |
|
213 | - { |
|
214 | - echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
215 | - } |
|
216 | - echo "\t</tr>\n"; |
|
209 | + // the header |
|
210 | + echo "\t<tr>\n"; |
|
211 | + echo "\t\t<th>".get_lang('Module')."</th>\n"; |
|
212 | + foreach ($header_array as $header_key=>$header_value) |
|
213 | + { |
|
214 | + echo "\t\t<th>".get_lang($header_value)."</th>\n"; |
|
215 | + } |
|
216 | + echo "\t</tr>\n"; |
|
217 | 217 | |
218 | - // the main area with the checkboxes or images |
|
219 | - foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
220 | - { |
|
221 | - echo "\t<tr>\n"; |
|
222 | - echo "\t\t<td>\n"; |
|
223 | - echo get_lang($tool); |
|
224 | - echo "\t\t</td>\n"; |
|
218 | + // the main area with the checkboxes or images |
|
219 | + foreach ($tool_rights as $tool=>$rights) // $tool_rights contains all the possible tools and their rights |
|
220 | + { |
|
221 | + echo "\t<tr>\n"; |
|
222 | + echo "\t\t<td>\n"; |
|
223 | + echo get_lang($tool); |
|
224 | + echo "\t\t</td>\n"; |
|
225 | 225 | |
226 | - foreach ($header_array as $key=>$value) |
|
227 | - { |
|
228 | - echo "\t\t<td align='center'>\n"; |
|
229 | - if (in_array($value,$rights)) |
|
230 | - { |
|
231 | - if ($setting_visualisation=='checkbox') |
|
232 | - { |
|
233 | - display_checkbox_matrix($current_role_permissions, $tool, $value); |
|
234 | - } |
|
235 | - if ($setting_visualisation=='image') |
|
236 | - { |
|
237 | - if ($_GET['scope']=='platform') |
|
238 | - { |
|
239 | - $roles_editable=false; |
|
240 | - } |
|
241 | - else |
|
242 | - { |
|
243 | - $roles_editable=true; |
|
244 | - } |
|
245 | - display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable); |
|
246 | - } |
|
247 | - } |
|
248 | - echo "\t\t</td>\n"; |
|
249 | - } |
|
250 | - echo "\t</tr>\n"; |
|
251 | - } |
|
226 | + foreach ($header_array as $key=>$value) |
|
227 | + { |
|
228 | + echo "\t\t<td align='center'>\n"; |
|
229 | + if (in_array($value,$rights)) |
|
230 | + { |
|
231 | + if ($setting_visualisation=='checkbox') |
|
232 | + { |
|
233 | + display_checkbox_matrix($current_role_permissions, $tool, $value); |
|
234 | + } |
|
235 | + if ($setting_visualisation=='image') |
|
236 | + { |
|
237 | + if ($_GET['scope']=='platform') |
|
238 | + { |
|
239 | + $roles_editable=false; |
|
240 | + } |
|
241 | + else |
|
242 | + { |
|
243 | + $roles_editable=true; |
|
244 | + } |
|
245 | + display_image_matrix($current_role_permissions, $tool, $value, '','',$roles_editable); |
|
246 | + } |
|
247 | + } |
|
248 | + echo "\t\t</td>\n"; |
|
249 | + } |
|
250 | + echo "\t</tr>\n"; |
|
251 | + } |
|
252 | 252 | |
253 | - echo "</table>\n"; |
|
254 | - if ($setting_visualisation=='checkbox') |
|
255 | - { |
|
256 | - echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
257 | - } |
|
258 | - echo "</form>"; |
|
253 | + echo "</table>\n"; |
|
254 | + if ($setting_visualisation=='checkbox') |
|
255 | + { |
|
256 | + echo "<input type=\"Submit\" name=\"StoreRolePermissions\" value=\"".get_lang('StorePermissions')."\">"; |
|
257 | + } |
|
258 | + echo "</form>"; |
|
259 | 259 | } |
260 | 260 | Display::display_footer(); |
261 | 261 | \ No newline at end of file |
@@ -5,7 +5,7 @@ |
||
5 | 5 | */ |
6 | 6 | $ip = trim($_SERVER['REMOTE_ADDR']); |
7 | 7 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
8 | - list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
9 | - $ip = trim($ip1); |
|
8 | + list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
9 | + $ip = trim($ip1); |
|
10 | 10 | } |
11 | 11 | echo htmlentities($ip); |
@@ -11,32 +11,32 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class WSReport extends WS { |
13 | 13 | |
14 | - /** |
|
15 | - * Gets the time spent on the platform by a given user |
|
16 | - * |
|
17 | - * @param string User id field name |
|
18 | - * @param string User id value |
|
14 | + /** |
|
15 | + * Gets the time spent on the platform by a given user |
|
16 | + * |
|
17 | + * @param string User id field name |
|
18 | + * @param string User id value |
|
19 | 19 | * @return array Array of results |
20 | - */ |
|
21 | - public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) { |
|
22 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
23 | - if($user_id instanceof WSError) { |
|
24 | - return $user_id; |
|
25 | - } else { |
|
20 | + */ |
|
21 | + public function GetTimeSpentOnPlatform($user_id_field_name, $user_id_value) { |
|
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 | 26 | return Tracking::get_time_spent_on_the_platform($user_id); |
27 | - } |
|
28 | - } |
|
27 | + } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * Gets the time spent in a course by a given user |
32 | - * |
|
32 | + * |
|
33 | 33 | * @param string User id field name |
34 | 34 | * @param string User id value |
35 | 35 | * @param string Course id field name |
36 | 36 | * @param string Course id value |
37 | - * @return array Array of results |
|
38 | - */ |
|
39 | - public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
|
37 | + * @return array Array of results |
|
38 | + */ |
|
39 | + public function GetTimeSpentOnCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) { |
|
40 | 40 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
41 | 41 | if($user_id instanceof WSError) { |
42 | 42 | return $user_id; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
49 | 49 | } |
50 | 50 | return Tracking::get_time_spent_on_the_course($user_id, $course_id); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Gets the time spent in a course by a given user |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | } |
129 | 129 | $lp = new learnpath($course_code, $learnpath_id, $user_id); |
130 | 130 | $return = array( |
131 | - 'progress_bar_mode' => $lp->progress_bar_mode, |
|
132 | - 'progress_db' => $lp->progress_db, |
|
131 | + 'progress_bar_mode' => $lp->progress_bar_mode, |
|
132 | + 'progress_db' => $lp->progress_db, |
|
133 | 133 | ); |
134 | 134 | return $return; |
135 | 135 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | |
192 | 192 | $lp = new learnpath($course_code, $learnpath_id, $user_id); |
193 | 193 | $return = array( |
194 | - 'min_score' => $lp->items[$learnpath_item_id]->min_score, |
|
195 | - 'max_score' => $lp->items[$learnpath_item_id]->max_score, |
|
196 | - 'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score, |
|
197 | - 'current_score' => $lp->items[$learnpath_item_id]->current_score, |
|
194 | + 'min_score' => $lp->items[$learnpath_item_id]->min_score, |
|
195 | + 'max_score' => $lp->items[$learnpath_item_id]->max_score, |
|
196 | + 'mastery_score' => $lp->items[$learnpath_item_id]->mastery_score, |
|
197 | + 'current_score' => $lp->items[$learnpath_item_id]->current_score, |
|
198 | 198 | ); |
199 | 199 | return $return; |
200 | 200 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | global $charset; |
97 | 97 | if ($this->verifyUserPass($username, $password) == "valid") { |
98 | - $user_id = UserManager::get_user_id_from_username($username); |
|
98 | + $user_id = UserManager::get_user_id_from_username($username); |
|
99 | 99 | $message_title = get_lang('Invitation'); |
100 | 100 | $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
101 | 101 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | /** |
138 | - * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
139 | - * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
140 | - * @param array $order_by a list of fields on which sort |
|
141 | - * @return array An array with all users of the platform. |
|
142 | - * @todo optional course code parameter, optional sorting parameters... |
|
138 | + * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
139 | + * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
140 | + * @param array $order_by a list of fields on which sort |
|
141 | + * @return array An array with all users of the platform. |
|
142 | + * @todo optional course code parameter, optional sorting parameters... |
|
143 | 143 | *@todo Use the UserManager class |
144 | 144 | * @todo security filter order by |
145 | - */ |
|
145 | + */ |
|
146 | 146 | private static function get_user_list_like_start($conditions = array(), $order_by = array()) |
147 | 147 | { |
148 | 148 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -581,7 +581,7 @@ |
||
581 | 581 | /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null; |
582 | 582 | $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/ |
583 | 583 | |
584 | - $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
584 | + $courseInfo = CourseManager::getCourseInfoFromOriginalId( |
|
585 | 585 | $courseIdValue, |
586 | 586 | $courseIdName |
587 | 587 | ); |
@@ -9,255 +9,255 @@ discard block |
||
9 | 9 | $s = WSCMSoapServer::singleton(); |
10 | 10 | |
11 | 11 | $s->wsdl->addComplexType( |
12 | - 'course_id', |
|
13 | - 'complexType', |
|
14 | - 'struct', |
|
15 | - 'all', |
|
16 | - '', |
|
17 | - array( |
|
18 | - 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
19 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string') |
|
20 | - ) |
|
12 | + 'course_id', |
|
13 | + 'complexType', |
|
14 | + 'struct', |
|
15 | + 'all', |
|
16 | + '', |
|
17 | + array( |
|
18 | + 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
19 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string') |
|
20 | + ) |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | $s->wsdl->addComplexType( |
24 | - 'course_result', |
|
25 | - 'complexType', |
|
26 | - 'struct', |
|
27 | - 'all', |
|
28 | - '', |
|
29 | - array( |
|
30 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
31 | - 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
32 | - ) |
|
24 | + 'course_result', |
|
25 | + 'complexType', |
|
26 | + 'struct', |
|
27 | + 'all', |
|
28 | + '', |
|
29 | + array( |
|
30 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
31 | + 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
32 | + ) |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | $s->wsdl->addComplexType( |
36 | - 'course_result_array', |
|
37 | - 'complexType', |
|
38 | - 'array', |
|
39 | - '', |
|
40 | - 'SOAP-ENC:Array', |
|
41 | - array(), |
|
42 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')), |
|
43 | - 'tns:course_result' |
|
36 | + 'course_result_array', |
|
37 | + 'complexType', |
|
38 | + 'array', |
|
39 | + '', |
|
40 | + 'SOAP-ENC:Array', |
|
41 | + array(), |
|
42 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')), |
|
43 | + 'tns:course_result' |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | $s->register( |
47 | - 'WSCMCourse.DeleteCourse', |
|
48 | - array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string') |
|
47 | + 'WSCMCourse.DeleteCourse', |
|
48 | + array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string') |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | $s->register( |
52 | - 'WSCMCourse.DeleteCourses', |
|
53 | - array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'), |
|
54 | - array('return' => 'tns:course_result_array') |
|
52 | + 'WSCMCourse.DeleteCourses', |
|
53 | + array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'), |
|
54 | + array('return' => 'tns:course_result_array') |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | $s->register( |
58 | - 'WSCMCourse.CreateCourse', |
|
59 | - array( |
|
60 | - 'secret_key' => 'xsd:string', |
|
61 | - 'title' => 'xsd:string', |
|
62 | - 'category_code' => 'xsd:string', |
|
63 | - 'wanted_code' => 'xsd:string', |
|
64 | - 'tutor_name' => 'xsd:string', |
|
65 | - 'course_admin_user_id_field_name' => 'xsd:string', |
|
66 | - 'course_admin_user_id_value' => 'xsd:string', |
|
67 | - 'language' => 'xsd:string', |
|
68 | - 'course_id_field_name' => 'xsd:string', |
|
69 | - 'course_id_value' => 'xsd:string', |
|
70 | - 'extras' => 'tns:extra_field[]' |
|
71 | - ), |
|
72 | - array('return' => 'xsd:int') |
|
58 | + 'WSCMCourse.CreateCourse', |
|
59 | + array( |
|
60 | + 'secret_key' => 'xsd:string', |
|
61 | + 'title' => 'xsd:string', |
|
62 | + 'category_code' => 'xsd:string', |
|
63 | + 'wanted_code' => 'xsd:string', |
|
64 | + 'tutor_name' => 'xsd:string', |
|
65 | + 'course_admin_user_id_field_name' => 'xsd:string', |
|
66 | + 'course_admin_user_id_value' => 'xsd:string', |
|
67 | + 'language' => 'xsd:string', |
|
68 | + 'course_id_field_name' => 'xsd:string', |
|
69 | + 'course_id_value' => 'xsd:string', |
|
70 | + 'extras' => 'tns:extra_field[]' |
|
71 | + ), |
|
72 | + array('return' => 'xsd:int') |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | $s->wsdl->addComplexType( |
76 | - 'course_create', |
|
77 | - 'complexType', |
|
78 | - 'struct', |
|
79 | - 'all', |
|
80 | - '', |
|
81 | - array( |
|
82 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
83 | - 'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'), |
|
84 | - 'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'), |
|
85 | - 'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'), |
|
86 | - 'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'), |
|
87 | - 'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'), |
|
88 | - 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
89 | - 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
90 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
91 | - 'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]') |
|
92 | - ) |
|
76 | + 'course_create', |
|
77 | + 'complexType', |
|
78 | + 'struct', |
|
79 | + 'all', |
|
80 | + '', |
|
81 | + array( |
|
82 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
83 | + 'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'), |
|
84 | + 'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'), |
|
85 | + 'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'), |
|
86 | + 'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'), |
|
87 | + 'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'), |
|
88 | + 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
89 | + 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
90 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
91 | + 'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]') |
|
92 | + ) |
|
93 | 93 | ); |
94 | 94 | |
95 | 95 | $s->wsdl->addComplexType( |
96 | - 'course_create_result', |
|
97 | - 'complexType', |
|
98 | - 'struct', |
|
99 | - 'all', |
|
100 | - '', |
|
101 | - array( |
|
102 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
103 | - 'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'), |
|
104 | - 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
105 | - ) |
|
96 | + 'course_create_result', |
|
97 | + 'complexType', |
|
98 | + 'struct', |
|
99 | + 'all', |
|
100 | + '', |
|
101 | + array( |
|
102 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
103 | + 'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'), |
|
104 | + 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
105 | + ) |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | $s->wsdl->addComplexType( |
109 | - 'course_create_result_array', |
|
110 | - 'complexType', |
|
111 | - 'array', |
|
112 | - '', |
|
113 | - 'SOAP-ENC:Array', |
|
114 | - array(), |
|
115 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')), |
|
116 | - 'tns:course_create_result' |
|
109 | + 'course_create_result_array', |
|
110 | + 'complexType', |
|
111 | + 'array', |
|
112 | + '', |
|
113 | + 'SOAP-ENC:Array', |
|
114 | + array(), |
|
115 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')), |
|
116 | + 'tns:course_create_result' |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | $s->register( |
120 | - 'WSCMCourse.CreateCourses', |
|
121 | - array( |
|
122 | - 'secret_key' => 'xsd:string', |
|
123 | - 'courses' => 'tns:course_create[]' |
|
124 | - ), |
|
125 | - array('return' => 'tns:course_create_result_array') |
|
120 | + 'WSCMCourse.CreateCourses', |
|
121 | + array( |
|
122 | + 'secret_key' => 'xsd:string', |
|
123 | + 'courses' => 'tns:course_create[]' |
|
124 | + ), |
|
125 | + array('return' => 'tns:course_create_result_array') |
|
126 | 126 | ); |
127 | 127 | |
128 | 128 | $s->register( |
129 | - 'WSCMCourse.EditCourse', |
|
130 | - array( |
|
131 | - 'secret_key' => 'xsd:string', |
|
132 | - 'course_id_field_name' => 'xsd:string', |
|
133 | - 'course_id_value' => 'xsd:string', |
|
134 | - 'title' => 'xsd:string', |
|
135 | - 'category_code' => 'xsd:string', |
|
136 | - 'department_name' => 'xsd:string', |
|
137 | - 'department_url' => 'xsd:string', |
|
138 | - 'language' => 'xsd:string', |
|
139 | - 'visibility' => 'xsd:int', |
|
140 | - 'subscribe' => 'xsd:int', |
|
141 | - 'unsubscribe' => 'xsd:int', |
|
142 | - 'visual_code' => 'xsd:string', |
|
143 | - 'extras' => 'tns:extra_field[]' |
|
144 | - ) |
|
129 | + 'WSCMCourse.EditCourse', |
|
130 | + array( |
|
131 | + 'secret_key' => 'xsd:string', |
|
132 | + 'course_id_field_name' => 'xsd:string', |
|
133 | + 'course_id_value' => 'xsd:string', |
|
134 | + 'title' => 'xsd:string', |
|
135 | + 'category_code' => 'xsd:string', |
|
136 | + 'department_name' => 'xsd:string', |
|
137 | + 'department_url' => 'xsd:string', |
|
138 | + 'language' => 'xsd:string', |
|
139 | + 'visibility' => 'xsd:int', |
|
140 | + 'subscribe' => 'xsd:int', |
|
141 | + 'unsubscribe' => 'xsd:int', |
|
142 | + 'visual_code' => 'xsd:string', |
|
143 | + 'extras' => 'tns:extra_field[]' |
|
144 | + ) |
|
145 | 145 | ); |
146 | 146 | |
147 | 147 | $s->wsdl->addComplexType( |
148 | - 'course', |
|
149 | - 'complexType', |
|
150 | - 'struct', |
|
151 | - 'all', |
|
152 | - '', |
|
153 | - array( |
|
154 | - 'id' => array('name' => 'id', 'type' => 'xsd:int'), |
|
155 | - 'code' => array('name' => 'code', 'type' => 'xsd:string'), |
|
156 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
157 | - 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
158 | - 'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'), |
|
159 | - 'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), |
|
160 | - 'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'), |
|
161 | - 'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'), |
|
162 | - ) |
|
148 | + 'course', |
|
149 | + 'complexType', |
|
150 | + 'struct', |
|
151 | + 'all', |
|
152 | + '', |
|
153 | + array( |
|
154 | + 'id' => array('name' => 'id', 'type' => 'xsd:int'), |
|
155 | + 'code' => array('name' => 'code', 'type' => 'xsd:string'), |
|
156 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
157 | + 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
158 | + 'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'), |
|
159 | + 'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), |
|
160 | + 'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'), |
|
161 | + 'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'), |
|
162 | + ) |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | $s->wsdl->addComplexType( |
166 | - 'course_array', |
|
167 | - 'complexType', |
|
168 | - 'array', |
|
169 | - '', |
|
170 | - 'SOAP-ENC:Array', |
|
171 | - array(), |
|
172 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), |
|
173 | - 'tns:course' |
|
166 | + 'course_array', |
|
167 | + 'complexType', |
|
168 | + 'array', |
|
169 | + '', |
|
170 | + 'SOAP-ENC:Array', |
|
171 | + array(), |
|
172 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), |
|
173 | + 'tns:course' |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | $s->register( |
177 | - 'WSCMCourse.ListCourses', |
|
178 | - array( |
|
179 | - 'secret_key' => 'xsd:string', |
|
180 | - 'course_id_field_name' => 'xsd:string' |
|
181 | - ), |
|
182 | - array('return' => 'tns:course_array') |
|
177 | + 'WSCMCourse.ListCourses', |
|
178 | + array( |
|
179 | + 'secret_key' => 'xsd:string', |
|
180 | + 'course_id_field_name' => 'xsd:string' |
|
181 | + ), |
|
182 | + array('return' => 'tns:course_array') |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | $s->register( |
186 | - 'WSCMCourse.SubscribeUserToCourse', |
|
187 | - array( |
|
188 | - 'secret_key' => 'xsd:string', |
|
189 | - 'course_id_field_name' => 'xsd:string', |
|
190 | - 'course_id_value' => 'xsd:string', |
|
191 | - 'user_id_field_name' => 'xsd:string', |
|
192 | - 'user_id_value' => 'xsd:string', |
|
193 | - 'status' => 'xsd:int' |
|
194 | - ) |
|
186 | + 'WSCMCourse.SubscribeUserToCourse', |
|
187 | + array( |
|
188 | + 'secret_key' => 'xsd:string', |
|
189 | + 'course_id_field_name' => 'xsd:string', |
|
190 | + 'course_id_value' => 'xsd:string', |
|
191 | + 'user_id_field_name' => 'xsd:string', |
|
192 | + 'user_id_value' => 'xsd:string', |
|
193 | + 'status' => 'xsd:int' |
|
194 | + ) |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | $s->register( |
198 | - 'WSCMCourse.UnsubscribeUserFromCourse', |
|
199 | - array( |
|
200 | - 'secret_key' => 'xsd:string', |
|
201 | - 'course_id_field_name' => 'xsd:string', |
|
202 | - 'course_id_value' => 'xsd:string', |
|
203 | - 'user_id_field_name' => 'xsd:string', |
|
204 | - 'user_id_value' => 'xsd:string' |
|
205 | - ) |
|
198 | + 'WSCMCourse.UnsubscribeUserFromCourse', |
|
199 | + array( |
|
200 | + 'secret_key' => 'xsd:string', |
|
201 | + 'course_id_field_name' => 'xsd:string', |
|
202 | + 'course_id_value' => 'xsd:string', |
|
203 | + 'user_id_field_name' => 'xsd:string', |
|
204 | + 'user_id_value' => 'xsd:string' |
|
205 | + ) |
|
206 | 206 | ); |
207 | 207 | |
208 | 208 | $s->wsdl->addComplexType( |
209 | - 'course_description', |
|
210 | - 'complexType', |
|
211 | - 'struct', |
|
212 | - 'all', |
|
213 | - '', |
|
214 | - array( |
|
215 | - 'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'), |
|
216 | - 'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'), |
|
217 | - 'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string') |
|
218 | - ) |
|
209 | + 'course_description', |
|
210 | + 'complexType', |
|
211 | + 'struct', |
|
212 | + 'all', |
|
213 | + '', |
|
214 | + array( |
|
215 | + 'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'), |
|
216 | + 'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'), |
|
217 | + 'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string') |
|
218 | + ) |
|
219 | 219 | ); |
220 | 220 | |
221 | 221 | $s->wsdl->addComplexType( |
222 | - 'course_description_array', |
|
223 | - 'complexType', |
|
224 | - 'array', |
|
225 | - '', |
|
226 | - 'SOAP-ENC:Array', |
|
227 | - array(), |
|
228 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')), |
|
229 | - 'tns:course_description' |
|
222 | + 'course_description_array', |
|
223 | + 'complexType', |
|
224 | + 'array', |
|
225 | + '', |
|
226 | + 'SOAP-ENC:Array', |
|
227 | + array(), |
|
228 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')), |
|
229 | + 'tns:course_description' |
|
230 | 230 | ); |
231 | 231 | |
232 | 232 | $s->register( |
233 | - 'WSCMCourse.GetCourseDescriptions', |
|
234 | - array( |
|
235 | - 'secret_key' => 'xsd:string', |
|
236 | - 'course_id_field_name' => 'xsd:string', |
|
237 | - 'course_id_value' => 'xsd:string' |
|
238 | - ), |
|
239 | - array('return' => 'tns:course_description_array') |
|
233 | + 'WSCMCourse.GetCourseDescriptions', |
|
234 | + array( |
|
235 | + 'secret_key' => 'xsd:string', |
|
236 | + 'course_id_field_name' => 'xsd:string', |
|
237 | + 'course_id_value' => 'xsd:string' |
|
238 | + ), |
|
239 | + array('return' => 'tns:course_description_array') |
|
240 | 240 | ); |
241 | 241 | |
242 | 242 | $s->register( |
243 | - 'WSCMCourse.EditCourseDescription', |
|
244 | - array( |
|
245 | - 'secret_key' => 'xsd:string', |
|
246 | - 'course_id_field_name' => 'xsd:string', |
|
247 | - 'course_id_value' => 'xsd:string', |
|
248 | - 'course_desc_id' => 'xsd:int', |
|
249 | - 'course_desc_title' => 'xsd:string', |
|
250 | - 'course_desc_content' => 'xsd:string' |
|
251 | - ) |
|
243 | + 'WSCMCourse.EditCourseDescription', |
|
244 | + array( |
|
245 | + 'secret_key' => 'xsd:string', |
|
246 | + 'course_id_field_name' => 'xsd:string', |
|
247 | + 'course_id_value' => 'xsd:string', |
|
248 | + 'course_desc_id' => 'xsd:int', |
|
249 | + 'course_desc_title' => 'xsd:string', |
|
250 | + 'course_desc_content' => 'xsd:string' |
|
251 | + ) |
|
252 | 252 | ); |
253 | 253 | |
254 | 254 | $s->register( |
255 | - 'WSCMCourse.unreadMessage', |
|
256 | - array( |
|
257 | - 'username' => 'xsd:string', |
|
258 | - 'password' => 'xsd:string', |
|
259 | - ), |
|
260 | - array('return' => 'xsd:string'), |
|
255 | + 'WSCMCourse.unreadMessage', |
|
256 | + array( |
|
257 | + 'username' => 'xsd:string', |
|
258 | + 'password' => 'xsd:string', |
|
259 | + ), |
|
260 | + array('return' => 'xsd:string'), |
|
261 | 261 | 'urn:WSCMService', |
262 | 262 | '', |
263 | 263 | '', |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | |
269 | 269 | |
270 | 270 | $s->register( |
271 | - 'WSCMCourse.getIdMessage', |
|
272 | - array( |
|
273 | - 'username' => 'xsd:string', |
|
274 | - 'password' => 'xsd:string', |
|
275 | - ), |
|
276 | - array('return' => 'xsd:string'), |
|
271 | + 'WSCMCourse.getIdMessage', |
|
272 | + array( |
|
273 | + 'username' => 'xsd:string', |
|
274 | + 'password' => 'xsd:string', |
|
275 | + ), |
|
276 | + array('return' => 'xsd:string'), |
|
277 | 277 | 'urn:WSCMService', |
278 | 278 | '', |
279 | 279 | '', |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 'all', |
27 | 27 | '', |
28 | 28 | array( |
29 | - 'name'=>'code' , 'type'=>'xsd:string', |
|
30 | - 'name'=>'title' , 'type'=>'xsd:string', |
|
31 | - 'name'=>'url' , 'type'=>'xsd:string', |
|
32 | - 'name'=>'teacher', 'type'=>'xsd:string', |
|
33 | - 'name'=>'language','type'=>'xsd:string', |
|
29 | + 'name'=>'code' , 'type'=>'xsd:string', |
|
30 | + 'name'=>'title' , 'type'=>'xsd:string', |
|
31 | + 'name'=>'url' , 'type'=>'xsd:string', |
|
32 | + 'name'=>'teacher', 'type'=>'xsd:string', |
|
33 | + 'name'=>'language','type'=>'xsd:string', |
|
34 | 34 | ) |
35 | 35 | ); |
36 | 36 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | // Register the method to expose |
52 | 52 | $server->register('WSCourseListOfUser', // method name |
53 | 53 | array('username' => 'xsd:string', |
54 | - 'signature' => 'xsd:string'), // input parameters |
|
54 | + 'signature' => 'xsd:string'), // input parameters |
|
55 | 55 | array('return' => 'xsd:Array'), // output parameters |
56 | 56 | 'urn:WSUserInfo', // namespace |
57 | 57 | 'urn:WSUserInfo#WSUserInfo', // soapaction |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $list = UserManager::get_api_keys($user_id, 'dokeos'); |
78 | 78 | $key = ''; |
79 | 79 | foreach ($list as $key) { |
80 | - break; |
|
80 | + break; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $local_key = $username.$key; |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | // Register the method to expose |
130 | 130 | $server->register('WSEventsList', // method name |
131 | 131 | array('username' => 'xsd:string', |
132 | - 'signature' => 'xsd:string', |
|
133 | - 'datestart' => 'xsd:int', |
|
134 | - 'dateend' => 'xsd:int'), // input parameters |
|
132 | + 'signature' => 'xsd:string', |
|
133 | + 'datestart' => 'xsd:int', |
|
134 | + 'dateend' => 'xsd:int'), // input parameters |
|
135 | 135 | array('return' => 'xsd:Array'), // output parameters |
136 | 136 | 'urn:WSUserInfo', // namespace |
137 | 137 | 'urn:WSUserInfo#WSEventsList', // soapaction |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $list = UserManager::get_api_keys($user_id, 'dokeos'); |
160 | 160 | $key = ''; |
161 | 161 | foreach ($list as $key) { |
162 | - break; |
|
162 | + break; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $local_key = $username.$key; |
@@ -14,177 +14,177 @@ discard block |
||
14 | 14 | class WSSession extends WS |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Creates a session (helper method) |
|
19 | - * |
|
20 | - * @param string Name of the session |
|
21 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
22 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
23 | - * @param int Access delays of the coach (days before) |
|
24 | - * @param int Access delays of the coach (days after) |
|
25 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
26 | - * @param int Visibility |
|
27 | - * @param string User id field name for the coach |
|
28 | - * @param string User id value for the coach |
|
29 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
30 | - * @param string Original session id value |
|
31 | - * @param array Array of extra fields |
|
32 | - * @return mixed Generated id in case of success, WSError otherwise |
|
33 | - */ |
|
34 | - protected function createSessionHelper( |
|
35 | - $name, |
|
36 | - $start_date, |
|
37 | - $end_date, |
|
38 | - $nb_days_access_before, |
|
39 | - $nb_days_access_after, |
|
40 | - $nolimit, |
|
41 | - $visibility, |
|
42 | - $user_id_field_name, |
|
43 | - $user_id_value, |
|
44 | - $session_id_field_name, |
|
45 | - $session_id_value, |
|
46 | - $extras |
|
47 | - ) { |
|
48 | - // Verify that coach exists and get its id |
|
49 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
50 | - if ($user_id instanceof WSError) { |
|
51 | - return $user_id; |
|
52 | - } |
|
17 | + /** |
|
18 | + * Creates a session (helper method) |
|
19 | + * |
|
20 | + * @param string Name of the session |
|
21 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
22 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
23 | + * @param int Access delays of the coach (days before) |
|
24 | + * @param int Access delays of the coach (days after) |
|
25 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
26 | + * @param int Visibility |
|
27 | + * @param string User id field name for the coach |
|
28 | + * @param string User id value for the coach |
|
29 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
30 | + * @param string Original session id value |
|
31 | + * @param array Array of extra fields |
|
32 | + * @return mixed Generated id in case of success, WSError otherwise |
|
33 | + */ |
|
34 | + protected function createSessionHelper( |
|
35 | + $name, |
|
36 | + $start_date, |
|
37 | + $end_date, |
|
38 | + $nb_days_access_before, |
|
39 | + $nb_days_access_after, |
|
40 | + $nolimit, |
|
41 | + $visibility, |
|
42 | + $user_id_field_name, |
|
43 | + $user_id_value, |
|
44 | + $session_id_field_name, |
|
45 | + $session_id_value, |
|
46 | + $extras |
|
47 | + ) { |
|
48 | + // Verify that coach exists and get its id |
|
49 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
50 | + if ($user_id instanceof WSError) { |
|
51 | + return $user_id; |
|
52 | + } |
|
53 | 53 | |
54 | - $coachStartDate = null; |
|
55 | - if (!empty($nb_days_access_before)) { |
|
56 | - $day = intval($nb_days_access_before); |
|
57 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
58 | - } |
|
54 | + $coachStartDate = null; |
|
55 | + if (!empty($nb_days_access_before)) { |
|
56 | + $day = intval($nb_days_access_before); |
|
57 | + $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
58 | + } |
|
59 | 59 | |
60 | - $coachEndDate = null; |
|
61 | - if (!empty($nb_days_access_after)) { |
|
62 | - $day = intval($nb_days_access_after); |
|
63 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
64 | - } |
|
60 | + $coachEndDate = null; |
|
61 | + if (!empty($nb_days_access_after)) { |
|
62 | + $day = intval($nb_days_access_after); |
|
63 | + $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
64 | + } |
|
65 | 65 | |
66 | - // Try to create the session |
|
67 | - $session_id = SessionManager::create_session( |
|
68 | - $name, |
|
69 | - $start_date, |
|
70 | - $end_date, |
|
71 | - $start_date, |
|
72 | - $end_date, |
|
73 | - $coachStartDate, |
|
74 | - $coachEndDate, |
|
75 | - $user_id, |
|
76 | - 0, |
|
77 | - $visibility |
|
78 | - ); |
|
79 | - if(!is_int($session_id)) { |
|
80 | - return new WSError(301, 'Could not create the session'); |
|
81 | - } else { |
|
82 | - // Add the Original session id to the extra fields |
|
83 | - $extras_associative = array(); |
|
84 | - if($session_id_field_name != "chamilo_session_id") { |
|
85 | - $extras_associative[$session_id_field_name] = $session_id_value; |
|
86 | - } |
|
87 | - foreach($extras as $extra) { |
|
88 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
89 | - } |
|
90 | - // Create the extra fields |
|
91 | - foreach($extras_associative as $fname => $fvalue) { |
|
92 | - SessionManager::create_session_extra_field($fname, 1, $fname); |
|
93 | - SessionManager::update_session_extra_field_value( |
|
94 | - $session_id, |
|
95 | - $fname, |
|
96 | - $fvalue |
|
97 | - ); |
|
98 | - } |
|
99 | - return $session_id; |
|
100 | - } |
|
101 | - } |
|
66 | + // Try to create the session |
|
67 | + $session_id = SessionManager::create_session( |
|
68 | + $name, |
|
69 | + $start_date, |
|
70 | + $end_date, |
|
71 | + $start_date, |
|
72 | + $end_date, |
|
73 | + $coachStartDate, |
|
74 | + $coachEndDate, |
|
75 | + $user_id, |
|
76 | + 0, |
|
77 | + $visibility |
|
78 | + ); |
|
79 | + if(!is_int($session_id)) { |
|
80 | + return new WSError(301, 'Could not create the session'); |
|
81 | + } else { |
|
82 | + // Add the Original session id to the extra fields |
|
83 | + $extras_associative = array(); |
|
84 | + if($session_id_field_name != "chamilo_session_id") { |
|
85 | + $extras_associative[$session_id_field_name] = $session_id_value; |
|
86 | + } |
|
87 | + foreach($extras as $extra) { |
|
88 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
89 | + } |
|
90 | + // Create the extra fields |
|
91 | + foreach($extras_associative as $fname => $fvalue) { |
|
92 | + SessionManager::create_session_extra_field($fname, 1, $fname); |
|
93 | + SessionManager::update_session_extra_field_value( |
|
94 | + $session_id, |
|
95 | + $fname, |
|
96 | + $fvalue |
|
97 | + ); |
|
98 | + } |
|
99 | + return $session_id; |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Creates a session |
|
105 | - * |
|
106 | - * @param string API secret key |
|
107 | - * @param string Name of the session |
|
108 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
109 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
110 | - * @param int Access delays of the coach (days before) |
|
111 | - * @param int Access delays of the coach (days after) |
|
112 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
113 | - * @param int Visibility |
|
114 | - * @param string User id field name for the coach |
|
115 | - * @param string User id value for the coach |
|
116 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
117 | - * @param string Original session id value |
|
118 | - * @param array Array of extra fields |
|
119 | - * @return int Session id generated |
|
120 | - */ |
|
121 | - public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
122 | - $verifKey = $this->verifyKey($secret_key); |
|
123 | - if($verifKey instanceof WSError) { |
|
124 | - $this->handleError($verifKey); |
|
125 | - } else { |
|
126 | - $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
127 | - if($session_id instanceof WSError) { |
|
128 | - $this->handleError($session_id); |
|
129 | - } else { |
|
130 | - return $session_id; |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
103 | + /** |
|
104 | + * Creates a session |
|
105 | + * |
|
106 | + * @param string API secret key |
|
107 | + * @param string Name of the session |
|
108 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
109 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
110 | + * @param int Access delays of the coach (days before) |
|
111 | + * @param int Access delays of the coach (days after) |
|
112 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
113 | + * @param int Visibility |
|
114 | + * @param string User id field name for the coach |
|
115 | + * @param string User id value for the coach |
|
116 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
117 | + * @param string Original session id value |
|
118 | + * @param array Array of extra fields |
|
119 | + * @return int Session id generated |
|
120 | + */ |
|
121 | + public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
122 | + $verifKey = $this->verifyKey($secret_key); |
|
123 | + if($verifKey instanceof WSError) { |
|
124 | + $this->handleError($verifKey); |
|
125 | + } else { |
|
126 | + $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
127 | + if($session_id instanceof WSError) { |
|
128 | + $this->handleError($session_id); |
|
129 | + } else { |
|
130 | + return $session_id; |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Deletes a session (helper method) |
|
137 | - * |
|
138 | - * @param string Session id field name |
|
139 | - * @param string Session id value |
|
140 | - * @return mixed True in case of success, WSError otherwise |
|
141 | - */ |
|
142 | - protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
|
143 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
144 | - if($session_id instanceof WSError) { |
|
145 | - return $session_id; |
|
146 | - } else { |
|
147 | - SessionManager::delete($session_id, true); |
|
148 | - return true; |
|
149 | - } |
|
150 | - } |
|
135 | + /** |
|
136 | + * Deletes a session (helper method) |
|
137 | + * |
|
138 | + * @param string Session id field name |
|
139 | + * @param string Session id value |
|
140 | + * @return mixed True in case of success, WSError otherwise |
|
141 | + */ |
|
142 | + protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
|
143 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
144 | + if($session_id instanceof WSError) { |
|
145 | + return $session_id; |
|
146 | + } else { |
|
147 | + SessionManager::delete($session_id, true); |
|
148 | + return true; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * Deletes a session |
|
154 | - * |
|
155 | - * @param string API secret key |
|
156 | - * @param string Session id field name |
|
157 | - * @param string Session id value |
|
158 | - */ |
|
159 | - public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
|
160 | - $verifKey = $this->verifyKey($secret_key); |
|
161 | - if($verifKey instanceof WSError) { |
|
162 | - $this->handleError($verifKey); |
|
163 | - } else { |
|
164 | - $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
|
165 | - if($result instanceof WSError) { |
|
166 | - $this->handleError($result); |
|
167 | - } |
|
168 | - } |
|
169 | - } |
|
152 | + /** |
|
153 | + * Deletes a session |
|
154 | + * |
|
155 | + * @param string API secret key |
|
156 | + * @param string Session id field name |
|
157 | + * @param string Session id value |
|
158 | + */ |
|
159 | + public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
|
160 | + $verifKey = $this->verifyKey($secret_key); |
|
161 | + if($verifKey instanceof WSError) { |
|
162 | + $this->handleError($verifKey); |
|
163 | + } else { |
|
164 | + $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
|
165 | + if($result instanceof WSError) { |
|
166 | + $this->handleError($result); |
|
167 | + } |
|
168 | + } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Edits a session (helper method) |
|
173 | - * |
|
174 | - * @param string Name of the session |
|
175 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
176 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
177 | - * @param int Access delays of the coach (days before) |
|
178 | - * @param int Access delays of the coach (days after) |
|
179 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
180 | - * @param int Visibility |
|
181 | - * @param string User id field name for the coach |
|
182 | - * @param string User id value for the coach |
|
183 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
184 | - * @param string Original session id value |
|
185 | - * @param array Array of extra fields |
|
186 | - * @return mixed True on success, WSError otherwise |
|
187 | - */ |
|
171 | + /** |
|
172 | + * Edits a session (helper method) |
|
173 | + * |
|
174 | + * @param string Name of the session |
|
175 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
176 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
177 | + * @param int Access delays of the coach (days before) |
|
178 | + * @param int Access delays of the coach (days after) |
|
179 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
180 | + * @param int Visibility |
|
181 | + * @param string User id field name for the coach |
|
182 | + * @param string User id value for the coach |
|
183 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
184 | + * @param string Original session id value |
|
185 | + * @param array Array of extra fields |
|
186 | + * @return mixed True on success, WSError otherwise |
|
187 | + */ |
|
188 | 188 | protected function editSessionHelper( |
189 | 189 | $name, |
190 | 190 | $start_date, |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | $session_id_value, |
200 | 200 | $extras |
201 | 201 | ) { |
202 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
203 | - if($session_id instanceof WSError) { |
|
204 | - return $session_id; |
|
205 | - } else { |
|
206 | - // Verify that coach exists and get its id |
|
207 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
208 | - if ($user_id instanceof WSError) { |
|
209 | - return $user_id; |
|
210 | - } |
|
202 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
203 | + if($session_id instanceof WSError) { |
|
204 | + return $session_id; |
|
205 | + } else { |
|
206 | + // Verify that coach exists and get its id |
|
207 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
208 | + if ($user_id instanceof WSError) { |
|
209 | + return $user_id; |
|
210 | + } |
|
211 | 211 | |
212 | 212 | $coachStartDate = null; |
213 | 213 | if (!empty($nb_days_access_before)) { |
@@ -234,127 +234,127 @@ discard block |
||
234 | 234 | 0, |
235 | 235 | (int)$visibility |
236 | 236 | ); |
237 | - if(!is_int($result_id)) { |
|
238 | - return new WSError(302, 'Could not edit the session'); |
|
239 | - } else { |
|
240 | - if(!empty($extras)) { |
|
241 | - $extras_associative = array(); |
|
242 | - foreach($extras as $extra) { |
|
243 | - $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
244 | - } |
|
245 | - // Create the extra fields |
|
246 | - foreach($extras_associative as $fname => $fvalue) { |
|
247 | - SessionManager::create_session_extra_field($fname, 1, $fname); |
|
248 | - SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
|
249 | - } |
|
250 | - } |
|
251 | - return true; |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
237 | + if(!is_int($result_id)) { |
|
238 | + return new WSError(302, 'Could not edit the session'); |
|
239 | + } else { |
|
240 | + if(!empty($extras)) { |
|
241 | + $extras_associative = array(); |
|
242 | + foreach($extras as $extra) { |
|
243 | + $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
244 | + } |
|
245 | + // Create the extra fields |
|
246 | + foreach($extras_associative as $fname => $fvalue) { |
|
247 | + SessionManager::create_session_extra_field($fname, 1, $fname); |
|
248 | + SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
|
249 | + } |
|
250 | + } |
|
251 | + return true; |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Edits a session |
|
258 | - * |
|
259 | - * @param string API secret key |
|
260 | - * @param string Name of the session |
|
261 | - * @param string Start date, use the 'YYYY-MM-DD' format |
|
262 | - * @param string End date, use the 'YYYY-MM-DD' format |
|
263 | - * @param int Access delays of the coach (days before) |
|
264 | - * @param int Access delays of the coach (days after) |
|
265 | - * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
266 | - * @param int Visibility |
|
267 | - * @param string User id field name for the coach |
|
268 | - * @param string User id value for the coach |
|
269 | - * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
270 | - * @param string Original session id value |
|
271 | - * @param array Array of extra fields |
|
272 | - */ |
|
273 | - public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
274 | - $verifKey = $this->verifyKey($secret_key); |
|
275 | - if($verifKey instanceof WSError) { |
|
276 | - $this->handleError($verifKey); |
|
277 | - } else { |
|
278 | - $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
279 | - if($session_id_value instanceof WSError) { |
|
280 | - $this->handleError($result); |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
256 | + /** |
|
257 | + * Edits a session |
|
258 | + * |
|
259 | + * @param string API secret key |
|
260 | + * @param string Name of the session |
|
261 | + * @param string Start date, use the 'YYYY-MM-DD' format |
|
262 | + * @param string End date, use the 'YYYY-MM-DD' format |
|
263 | + * @param int Access delays of the coach (days before) |
|
264 | + * @param int Access delays of the coach (days after) |
|
265 | + * @param int Nolimit (0 = no limit of time, 1 = limit of time) |
|
266 | + * @param int Visibility |
|
267 | + * @param string User id field name for the coach |
|
268 | + * @param string User id value for the coach |
|
269 | + * @param string Original session id field name (use "chamilo_session_id" to use internal id) |
|
270 | + * @param string Original session id value |
|
271 | + * @param array Array of extra fields |
|
272 | + */ |
|
273 | + public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
|
274 | + $verifKey = $this->verifyKey($secret_key); |
|
275 | + if($verifKey instanceof WSError) { |
|
276 | + $this->handleError($verifKey); |
|
277 | + } else { |
|
278 | + $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
|
279 | + if($session_id_value instanceof WSError) { |
|
280 | + $this->handleError($result); |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Change user subscription (helper method) |
|
287 | - * |
|
288 | - * @param string User id field name |
|
289 | - * @param string User id value |
|
290 | - * @param string Session id field name |
|
291 | - * @param string Session id value |
|
292 | - * @param int State (1 to subscribe, 0 to unsubscribe) |
|
293 | - * @return mixed True on success, WSError otherwise |
|
294 | - */ |
|
295 | - protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
|
296 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
297 | - if($session_id instanceof WSError) { |
|
298 | - return $session_id; |
|
299 | - } else { |
|
300 | - $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
301 | - if($user_id instanceof WSError) { |
|
302 | - return $user_id; |
|
303 | - } else { |
|
304 | - if($state == 1) { |
|
305 | - SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
|
306 | - } else { |
|
307 | - $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
|
308 | - if (!$result) { |
|
309 | - return new WSError(303, 'There was an error unsubscribing this user from the session'); |
|
310 | - } |
|
311 | - } |
|
312 | - return true; |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
285 | + /** |
|
286 | + * Change user subscription (helper method) |
|
287 | + * |
|
288 | + * @param string User id field name |
|
289 | + * @param string User id value |
|
290 | + * @param string Session id field name |
|
291 | + * @param string Session id value |
|
292 | + * @param int State (1 to subscribe, 0 to unsubscribe) |
|
293 | + * @return mixed True on success, WSError otherwise |
|
294 | + */ |
|
295 | + protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
|
296 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
297 | + if($session_id instanceof WSError) { |
|
298 | + return $session_id; |
|
299 | + } else { |
|
300 | + $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
|
301 | + if($user_id instanceof WSError) { |
|
302 | + return $user_id; |
|
303 | + } else { |
|
304 | + if($state == 1) { |
|
305 | + SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
|
306 | + } else { |
|
307 | + $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
|
308 | + if (!$result) { |
|
309 | + return new WSError(303, 'There was an error unsubscribing this user from the session'); |
|
310 | + } |
|
311 | + } |
|
312 | + return true; |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Subscribe user to a session |
|
319 | - * |
|
320 | - * @param string API secret key |
|
321 | - * @param string User id field name |
|
322 | - * @param string User id value |
|
323 | - * @param string Session id field name |
|
324 | - * @param string Session id value |
|
325 | - */ |
|
326 | - public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
327 | - $verifKey = $this->verifyKey($secret_key); |
|
328 | - if($verifKey instanceof WSError) { |
|
329 | - $this->handleError($verifKey); |
|
330 | - } else { |
|
331 | - $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
|
332 | - if($result instanceof WSError) { |
|
333 | - $this->handleError($result); |
|
334 | - } |
|
335 | - } |
|
336 | - } |
|
317 | + /** |
|
318 | + * Subscribe user to a session |
|
319 | + * |
|
320 | + * @param string API secret key |
|
321 | + * @param string User id field name |
|
322 | + * @param string User id value |
|
323 | + * @param string Session id field name |
|
324 | + * @param string Session id value |
|
325 | + */ |
|
326 | + public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
327 | + $verifKey = $this->verifyKey($secret_key); |
|
328 | + if($verifKey instanceof WSError) { |
|
329 | + $this->handleError($verifKey); |
|
330 | + } else { |
|
331 | + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
|
332 | + if($result instanceof WSError) { |
|
333 | + $this->handleError($result); |
|
334 | + } |
|
335 | + } |
|
336 | + } |
|
337 | 337 | |
338 | - /** |
|
339 | - * Subscribe user to a session |
|
340 | - * |
|
341 | - * @param string API secret key |
|
342 | - * @param string User id field name |
|
343 | - * @param string User id value |
|
344 | - * @param string Session id field name |
|
345 | - * @param string Session id value |
|
346 | - */ |
|
347 | - public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
348 | - $verifKey = $this->verifyKey($secret_key); |
|
349 | - if($verifKey instanceof WSError) { |
|
350 | - $this->handleError($verifKey); |
|
351 | - } else { |
|
352 | - $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
|
353 | - if($result instanceof WSError) { |
|
354 | - $this->handleError($result); |
|
355 | - } |
|
356 | - } |
|
357 | - } |
|
338 | + /** |
|
339 | + * Subscribe user to a session |
|
340 | + * |
|
341 | + * @param string API secret key |
|
342 | + * @param string User id field name |
|
343 | + * @param string User id value |
|
344 | + * @param string Session id field name |
|
345 | + * @param string Session id value |
|
346 | + */ |
|
347 | + public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
|
348 | + $verifKey = $this->verifyKey($secret_key); |
|
349 | + if($verifKey instanceof WSError) { |
|
350 | + $this->handleError($verifKey); |
|
351 | + } else { |
|
352 | + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
|
353 | + if($result instanceof WSError) { |
|
354 | + $this->handleError($result); |
|
355 | + } |
|
356 | + } |
|
357 | + } |
|
358 | 358 | |
359 | 359 | /** |
360 | 360 | * Change Teacher subscription (helper method) |
@@ -446,79 +446,79 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
449 | - * Change course subscription |
|
450 | - * |
|
451 | - * @param string Course id field name |
|
452 | - * @param string Course id value |
|
453 | - * @param string Session id field name |
|
454 | - * @param string Session id value |
|
455 | - * @param int State (1 to subscribe, 0 to unsubscribe) |
|
456 | - * @return mixed True on success, WSError otherwise |
|
457 | - */ |
|
458 | - protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
|
459 | - $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
460 | - if($session_id instanceof WSError) { |
|
461 | - return $session_id; |
|
462 | - } else { |
|
463 | - $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
464 | - if($course_id instanceof WSError) { |
|
465 | - return $course_id; |
|
466 | - } else { |
|
467 | - if($state == 1) { |
|
468 | - SessionManager::add_courses_to_session($session_id, array($course_id)); |
|
469 | - return true; |
|
470 | - } else { |
|
471 | - $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id); |
|
472 | - if ($result) { |
|
473 | - return true; |
|
474 | - } else { |
|
475 | - return new WSError(304, 'Error unsubscribing course from session'); |
|
476 | - } |
|
477 | - } |
|
478 | - } |
|
479 | - } |
|
449 | + * Change course subscription |
|
450 | + * |
|
451 | + * @param string Course id field name |
|
452 | + * @param string Course id value |
|
453 | + * @param string Session id field name |
|
454 | + * @param string Session id value |
|
455 | + * @param int State (1 to subscribe, 0 to unsubscribe) |
|
456 | + * @return mixed True on success, WSError otherwise |
|
457 | + */ |
|
458 | + protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
|
459 | + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
|
460 | + if($session_id instanceof WSError) { |
|
461 | + return $session_id; |
|
462 | + } else { |
|
463 | + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
464 | + if($course_id instanceof WSError) { |
|
465 | + return $course_id; |
|
466 | + } else { |
|
467 | + if($state == 1) { |
|
468 | + SessionManager::add_courses_to_session($session_id, array($course_id)); |
|
469 | + return true; |
|
470 | + } else { |
|
471 | + $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id); |
|
472 | + if ($result) { |
|
473 | + return true; |
|
474 | + } else { |
|
475 | + return new WSError(304, 'Error unsubscribing course from session'); |
|
476 | + } |
|
477 | + } |
|
478 | + } |
|
479 | + } |
|
480 | 480 | } |
481 | 481 | |
482 | - /** |
|
483 | - * Subscribe course to session |
|
484 | - * |
|
485 | - * @param string API secret key |
|
486 | - * @param string Course id field name |
|
487 | - * @param string Course id value |
|
488 | - * @param string Session id field name |
|
489 | - * @param string Session id value |
|
490 | - */ |
|
491 | - public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
492 | - $verifKey = $this->verifyKey($secret_key); |
|
493 | - if($verifKey instanceof WSError) { |
|
494 | - $this->handleError($verifKey); |
|
495 | - } else { |
|
496 | - $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
|
497 | - if($result instanceof WSError) { |
|
498 | - $this->handleError($result); |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
482 | + /** |
|
483 | + * Subscribe course to session |
|
484 | + * |
|
485 | + * @param string API secret key |
|
486 | + * @param string Course id field name |
|
487 | + * @param string Course id value |
|
488 | + * @param string Session id field name |
|
489 | + * @param string Session id value |
|
490 | + */ |
|
491 | + public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
492 | + $verifKey = $this->verifyKey($secret_key); |
|
493 | + if($verifKey instanceof WSError) { |
|
494 | + $this->handleError($verifKey); |
|
495 | + } else { |
|
496 | + $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
|
497 | + if($result instanceof WSError) { |
|
498 | + $this->handleError($result); |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | 502 | |
503 | - /** |
|
504 | - * Unsubscribe course from session |
|
505 | - * |
|
506 | - * @param string API secret key |
|
507 | - * @param string Course id field name |
|
508 | - * @param string Course id value |
|
509 | - * @param string Session id field name |
|
510 | - * @param string Session id value |
|
511 | - */ |
|
512 | - public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
513 | - $verifKey = $this->verifyKey($secret_key); |
|
514 | - if($verifKey instanceof WSError) { |
|
515 | - $this->handleError($verifKey); |
|
516 | - } else { |
|
517 | - $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
|
518 | - if($result instanceof WSError) { |
|
519 | - $this->handleError($result); |
|
520 | - } |
|
521 | - } |
|
522 | - } |
|
503 | + /** |
|
504 | + * Unsubscribe course from session |
|
505 | + * |
|
506 | + * @param string API secret key |
|
507 | + * @param string Course id field name |
|
508 | + * @param string Course id value |
|
509 | + * @param string Session id field name |
|
510 | + * @param string Session id value |
|
511 | + */ |
|
512 | + public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
|
513 | + $verifKey = $this->verifyKey($secret_key); |
|
514 | + if($verifKey instanceof WSError) { |
|
515 | + $this->handleError($verifKey); |
|
516 | + } else { |
|
517 | + $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
|
518 | + if($result instanceof WSError) { |
|
519 | + $this->handleError($result); |
|
520 | + } |
|
521 | + } |
|
522 | + } |
|
523 | 523 | |
524 | 524 | } |
@@ -11,84 +11,84 @@ discard block |
||
11 | 11 | * SOAP error handler. Handles an error sending a SOAP fault |
12 | 12 | */ |
13 | 13 | class WSSoapErrorHandler implements WSErrorHandler { |
14 | - /** |
|
15 | - * Handles the error by sending a SOAP fault through the server |
|
16 | - * |
|
17 | - * @param WSError Error to handle |
|
18 | - */ |
|
19 | - public function handle($error) { |
|
20 | - $server = WSSoapServer::singleton(); |
|
21 | - $server->fault(strval($error->code), $error->message); |
|
22 | - } |
|
14 | + /** |
|
15 | + * Handles the error by sending a SOAP fault through the server |
|
16 | + * |
|
17 | + * @param WSError Error to handle |
|
18 | + */ |
|
19 | + public function handle($error) { |
|
20 | + $server = WSSoapServer::singleton(); |
|
21 | + $server->fault(strval($error->code), $error->message); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * SOAP server wrapper implementing a Singleton |
27 | 27 | */ |
28 | 28 | class WSSoapServer { |
29 | - /** |
|
30 | - * SOAP server instance |
|
31 | - * |
|
32 | - * @var soap_server |
|
33 | - */ |
|
34 | - private static $_instance; |
|
29 | + /** |
|
30 | + * SOAP server instance |
|
31 | + * |
|
32 | + * @var soap_server |
|
33 | + */ |
|
34 | + private static $_instance; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Private constructor |
|
38 | - */ |
|
39 | - private function __construct() { |
|
40 | - } |
|
36 | + /** |
|
37 | + * Private constructor |
|
38 | + */ |
|
39 | + private function __construct() { |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Singleton method |
|
44 | - */ |
|
45 | - public static function singleton() { |
|
46 | - if(!isset(self::$_instance)) { |
|
47 | - self::$_instance = new soap_server(); |
|
48 | - // Set the error handler |
|
49 | - WSError::setErrorHandler(new WSSoapErrorHandler()); |
|
50 | - // Configure the service |
|
51 | - self::$_instance->configureWSDL('WSService', 'urn:WSService'); |
|
52 | - } |
|
42 | + /** |
|
43 | + * Singleton method |
|
44 | + */ |
|
45 | + public static function singleton() { |
|
46 | + if(!isset(self::$_instance)) { |
|
47 | + self::$_instance = new soap_server(); |
|
48 | + // Set the error handler |
|
49 | + WSError::setErrorHandler(new WSSoapErrorHandler()); |
|
50 | + // Configure the service |
|
51 | + self::$_instance->configureWSDL('WSService', 'urn:WSService'); |
|
52 | + } |
|
53 | 53 | |
54 | - return self::$_instance; |
|
55 | - } |
|
54 | + return self::$_instance; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $s = WSSoapServer::singleton(); |
59 | 59 | |
60 | 60 | $s->wsdl->addComplexType( |
61 | - 'result', |
|
62 | - 'complexType', |
|
63 | - 'struct', |
|
64 | - 'all', |
|
65 | - '', |
|
66 | - array( |
|
67 | - 'code' => array('name' => 'code', 'type' => 'xsd:int'), |
|
68 | - 'message' => array('name' => 'message', 'type' => 'xsd:string') |
|
69 | - ) |
|
61 | + 'result', |
|
62 | + 'complexType', |
|
63 | + 'struct', |
|
64 | + 'all', |
|
65 | + '', |
|
66 | + array( |
|
67 | + 'code' => array('name' => 'code', 'type' => 'xsd:int'), |
|
68 | + 'message' => array('name' => 'message', 'type' => 'xsd:string') |
|
69 | + ) |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $s->wsdl->addComplexType( |
73 | - 'extras', |
|
74 | - 'complexType', |
|
75 | - 'struct', |
|
76 | - 'all', |
|
77 | - '', |
|
78 | - array( |
|
79 | - 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), |
|
80 | - 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') |
|
81 | - ) |
|
73 | + 'extras', |
|
74 | + 'complexType', |
|
75 | + 'struct', |
|
76 | + 'all', |
|
77 | + '', |
|
78 | + array( |
|
79 | + 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), |
|
80 | + 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') |
|
81 | + ) |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | $s->wsdl->addComplexType( |
85 | - 'extra_field', |
|
86 | - 'complexType', |
|
87 | - 'array', |
|
88 | - '', |
|
89 | - 'SOAP-ENC:Array', |
|
90 | - array(), |
|
91 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras' |
|
85 | + 'extra_field', |
|
86 | + 'complexType', |
|
87 | + 'array', |
|
88 | + '', |
|
89 | + 'SOAP-ENC:Array', |
|
90 | + array(), |
|
91 | + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras' |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | /* |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | |
108 | 108 | $s->register( |
109 | - 'WS.test', |
|
110 | - array(), |
|
111 | - array('return' => 'xsd:string') |
|
109 | + 'WS.test', |
|
110 | + array(), |
|
111 | + array('return' => 'xsd:string') |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | require_once(dirname(__FILE__).'/soap_user.php'); |