Passed
Push — 1.10.x ( aa45ad...6deddd )
by Yannick
44:37
created
main/webservices/soap_course.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -13,44 +13,44 @@  discard block
 block discarded – undo
13 13
 $s = WSSoapServer::singleton();
14 14
 
15 15
 $s->wsdl->addComplexType(
16
-	'course_id',
17
-	'complexType',
18
-	'struct',
19
-	'all',
20
-	'',
21
-	array(
22
-		'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
23
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
24
-	)
16
+    'course_id',
17
+    'complexType',
18
+    'struct',
19
+    'all',
20
+    '',
21
+    array(
22
+        'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
23
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
24
+    )
25 25
 );
26 26
 
27 27
 $s->wsdl->addComplexType(
28
-	'course_result',
29
-	'complexType',
30
-	'struct',
31
-	'all',
32
-	'',
33
-	array(
34
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
35
-		'result' => array('name' => 'result', 'type' => 'tns:result')
36
-	)
28
+    'course_result',
29
+    'complexType',
30
+    'struct',
31
+    'all',
32
+    '',
33
+    array(
34
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
35
+        'result' => array('name' => 'result', 'type' => 'tns:result')
36
+    )
37 37
 );
38 38
 
39 39
 $s->wsdl->addComplexType(
40
-	'course_result_array',
41
-	'complexType',
42
-	'array',
43
-	'',
44
-	'SOAP-ENC:Array',
45
-	array(),
46
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
47
-	'tns:course_result'
40
+    'course_result_array',
41
+    'complexType',
42
+    'array',
43
+    '',
44
+    'SOAP-ENC:Array',
45
+    array(),
46
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')),
47
+    'tns:course_result'
48 48
 );
49 49
 
50 50
 $s->register(
51
-	'WSCourse.DeleteCourse',
52
-	array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string'),
53
-	array(),
51
+    'WSCourse.DeleteCourse',
52
+    array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string'),
53
+    array(),
54 54
     'urn:WSService',                               // namespace
55 55
     'urn:WSService#WSCourse.DeleteCourse',         // soapaction
56 56
     'rpc',                                         // style
@@ -60,206 +60,206 @@  discard block
 block discarded – undo
60 60
 );
61 61
 
62 62
 $s->register(
63
-	'WSCourse.DeleteCourses',
64
-	array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
65
-	array('return' => 'tns:course_result_array')
63
+    'WSCourse.DeleteCourses',
64
+    array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'),
65
+    array('return' => 'tns:course_result_array')
66 66
 );
67 67
 
68 68
 $s->register(
69
-	'WSCourse.CreateCourse',
70
-	array(
71
-		'secret_key' => 'xsd:string',
72
-		'title' => 'xsd:string',
73
-		'category_code' => 'xsd:string',
74
-		'wanted_code' => 'xsd:string',
75
-		'tutor_name' => 'xsd:string',
76
-		'course_admin_user_id_field_name' => 'xsd:string',
77
-		'course_admin_user_id_value' => 'xsd:string',
78
-		'language' => 'xsd:string',
79
-		'course_id_field_name' => 'xsd:string',
80
-		'course_id_value' => 'xsd:string',
81
-		'extras' => 'tns:extra_field'
82
-	),
83
-	array('return' => 'xsd:int')
69
+    'WSCourse.CreateCourse',
70
+    array(
71
+        'secret_key' => 'xsd:string',
72
+        'title' => 'xsd:string',
73
+        'category_code' => 'xsd:string',
74
+        'wanted_code' => 'xsd:string',
75
+        'tutor_name' => 'xsd:string',
76
+        'course_admin_user_id_field_name' => 'xsd:string',
77
+        'course_admin_user_id_value' => 'xsd:string',
78
+        'language' => 'xsd:string',
79
+        'course_id_field_name' => 'xsd:string',
80
+        'course_id_value' => 'xsd:string',
81
+        'extras' => 'tns:extra_field'
82
+    ),
83
+    array('return' => 'xsd:int')
84 84
 );
85 85
 
86 86
 $s->wsdl->addComplexType(
87
-	'course_create',
88
-	'complexType',
89
-	'struct',
90
-	'all',
91
-	'',
92
-	array(
93
-		'title' => array('name' => 'title', 'type' => 'xsd:string'),
94
-		'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
95
-		'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
96
-		'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
97
-		'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
98
-		'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
99
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
100
-		'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
101
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
102
-		'extras' => array('name' => 'extras', 'type' => 'tns:extra_field')
103
-	)
87
+    'course_create',
88
+    'complexType',
89
+    'struct',
90
+    'all',
91
+    '',
92
+    array(
93
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
94
+        'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'),
95
+        'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'),
96
+        'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'),
97
+        'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'),
98
+        'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'),
99
+        'language' => array('name' => 'language', 'type' => 'xsd:string'),
100
+        'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
101
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
102
+        'extras' => array('name' => 'extras', 'type' => 'tns:extra_field')
103
+    )
104 104
 );
105 105
 
106 106
 $s->wsdl->addComplexType(
107
-	'course_create_result',
108
-	'complexType',
109
-	'struct',
110
-	'all',
111
-	'',
112
-	array(
113
-		'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
114
-		'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
115
-		'result' => array('name' => 'result', 'type' => 'tns:result')
116
-	)
107
+    'course_create_result',
108
+    'complexType',
109
+    'struct',
110
+    'all',
111
+    '',
112
+    array(
113
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
114
+        'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'),
115
+        'result' => array('name' => 'result', 'type' => 'tns:result')
116
+    )
117 117
 );
118 118
 
119 119
 $s->wsdl->addComplexType(
120
-	'course_create_result_array',
121
-	'complexType',
122
-	'array',
123
-	'',
124
-	'SOAP-ENC:Array',
125
-	array(),
126
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
127
-	'tns:course_create_result'
120
+    'course_create_result_array',
121
+    'complexType',
122
+    'array',
123
+    '',
124
+    'SOAP-ENC:Array',
125
+    array(),
126
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')),
127
+    'tns:course_create_result'
128 128
 );
129 129
 
130 130
 $s->register(
131
-	'WSCourse.CreateCourses',
132
-	array(
133
-		'secret_key' => 'xsd:string',
134
-		'courses' => 'tns:course_create[]'
135
-	),
136
-	array('return' => 'tns:course_create_result_array')
131
+    'WSCourse.CreateCourses',
132
+    array(
133
+        'secret_key' => 'xsd:string',
134
+        'courses' => 'tns:course_create[]'
135
+    ),
136
+    array('return' => 'tns:course_create_result_array')
137 137
 );
138 138
 
139 139
 $s->register(
140
-	'WSCourse.EditCourse',
141
-	array(
142
-		'secret_key' => 'xsd:string',
143
-		'course_id_field_name' => 'xsd:string',
144
-		'course_id_value' => 'xsd:string',
145
-		'title' => 'xsd:string',
146
-		'category_code' => 'xsd:string',
147
-		'department_name' => 'xsd:string',
148
-		'department_url' => 'xsd:string',
149
-		'language' => 'xsd:string',
150
-		'visibility' => 'xsd:int',
151
-		'subscribe' => 'xsd:int',
152
-		'unsubscribe' => 'xsd:int',
153
-		'visual_code' => 'xsd:string',
154
-		'extras' => 'tns:extra_field'
155
-	)
140
+    'WSCourse.EditCourse',
141
+    array(
142
+        'secret_key' => 'xsd:string',
143
+        'course_id_field_name' => 'xsd:string',
144
+        'course_id_value' => 'xsd:string',
145
+        'title' => 'xsd:string',
146
+        'category_code' => 'xsd:string',
147
+        'department_name' => 'xsd:string',
148
+        'department_url' => 'xsd:string',
149
+        'language' => 'xsd:string',
150
+        'visibility' => 'xsd:int',
151
+        'subscribe' => 'xsd:int',
152
+        'unsubscribe' => 'xsd:int',
153
+        'visual_code' => 'xsd:string',
154
+        'extras' => 'tns:extra_field'
155
+    )
156 156
 );
157 157
 
158 158
 $s->wsdl->addComplexType(
159
-	'course',
160
-	'complexType',
161
-	'struct',
162
-	'all',
163
-	'',
164
-	array(
165
-		'id' => array('name' => 'id', 'type' => 'xsd:int'),
166
-		'code' => array('name' => 'code', 'type' => 'xsd:string'),
167
-		'title' => array('name' => 'title', 'type' => 'xsd:string'),
168
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
169
-		'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
170
-		'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
171
-		'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
172
-		'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
173
-	)
159
+    'course',
160
+    'complexType',
161
+    'struct',
162
+    'all',
163
+    '',
164
+    array(
165
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
166
+        'code' => array('name' => 'code', 'type' => 'xsd:string'),
167
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
168
+        'language' => array('name' => 'language', 'type' => 'xsd:string'),
169
+        'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
170
+        'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'),
171
+        'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'),
172
+        'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'),
173
+    )
174 174
 );
175 175
 
176 176
 $s->wsdl->addComplexType(
177
-	'course_array',
178
-	'complexType',
179
-	'array',
180
-	'',
181
-	'SOAP-ENC:Array',
182
-	array(),
183
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
184
-	'tns:course'
177
+    'course_array',
178
+    'complexType',
179
+    'array',
180
+    '',
181
+    'SOAP-ENC:Array',
182
+    array(),
183
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')),
184
+    'tns:course'
185 185
 );
186 186
 
187 187
 $s->register(
188
-	'WSCourse.ListCourses',
189
-	array(
190
-		'secret_key' => 'xsd:string',
191
-		'course_id_field_name' => 'xsd:string',
192
-		'visibilities' => 'xsd:string'
193
-	),
194
-	array('return' => 'tns:course_array')
188
+    'WSCourse.ListCourses',
189
+    array(
190
+        'secret_key' => 'xsd:string',
191
+        'course_id_field_name' => 'xsd:string',
192
+        'visibilities' => 'xsd:string'
193
+    ),
194
+    array('return' => 'tns:course_array')
195 195
 );
196 196
 
197 197
 $s->register(
198
-	'WSCourse.SubscribeUserToCourse',
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
-		'status' => 'xsd:int'
206
-	)
198
+    'WSCourse.SubscribeUserToCourse',
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
+        'status' => 'xsd:int'
206
+    )
207 207
 );
208 208
 
209 209
 $s->register(
210
-	'WSCourse.UnsubscribeUserFromCourse',
211
-	array(
212
-		'secret_key' => 'xsd:string',
213
-		'course_id_field_name' => 'xsd:string',
214
-		'course_id_value' => 'xsd:string',
215
-		'user_id_field_name' => 'xsd:string',
216
-		'user_id_value' => 'xsd:string'
217
-	)
210
+    'WSCourse.UnsubscribeUserFromCourse',
211
+    array(
212
+        'secret_key' => 'xsd:string',
213
+        'course_id_field_name' => 'xsd:string',
214
+        'course_id_value' => 'xsd:string',
215
+        'user_id_field_name' => 'xsd:string',
216
+        'user_id_value' => 'xsd:string'
217
+    )
218 218
 );
219 219
 
220 220
 $s->wsdl->addComplexType(
221
-	'course_description',
222
-	'complexType',
223
-	'struct',
224
-	'all',
225
-	'',
226
-	array(
227
-		'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
228
-		'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
229
-		'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
230
-	)
221
+    'course_description',
222
+    'complexType',
223
+    'struct',
224
+    'all',
225
+    '',
226
+    array(
227
+        'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'),
228
+        'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'),
229
+        'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string')
230
+    )
231 231
 );
232 232
 
233 233
 $s->wsdl->addComplexType(
234
-	'course_description_array',
235
-	'complexType',
236
-	'array',
237
-	'',
238
-	'SOAP-ENC:Array',
239
-	array(),
240
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
241
-	'tns:course_description'
234
+    'course_description_array',
235
+    'complexType',
236
+    'array',
237
+    '',
238
+    'SOAP-ENC:Array',
239
+    array(),
240
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')),
241
+    'tns:course_description'
242 242
 );
243 243
 
244 244
 $s->register(
245
-	'WSCourse.GetCourseDescriptions',
246
-	array(
247
-		'secret_key' => 'xsd:string',
248
-		'course_id_field_name' => 'xsd:string',
249
-		'course_id_value' => 'xsd:string'
250
-	),
251
-	array('return' => 'tns:course_description_array')
245
+    'WSCourse.GetCourseDescriptions',
246
+    array(
247
+        'secret_key' => 'xsd:string',
248
+        'course_id_field_name' => 'xsd:string',
249
+        'course_id_value' => 'xsd:string'
250
+    ),
251
+    array('return' => 'tns:course_description_array')
252 252
 );
253 253
 
254 254
 $s->register(
255
-	'WSCourse.EditCourseDescription',
256
-	array(
257
-		'secret_key' => 'xsd:string',
258
-		'course_id_field_name' => 'xsd:string',
259
-		'course_id_value' => 'xsd:string',
260
-		'course_desc_id' => 'xsd:int',
261
-		'course_desc_title' => 'xsd:string',
262
-		'course_desc_content' => 'xsd:string'
263
-	)
255
+    'WSCourse.EditCourseDescription',
256
+    array(
257
+        'secret_key' => 'xsd:string',
258
+        'course_id_field_name' => 'xsd:string',
259
+        'course_id_value' => 'xsd:string',
260
+        'course_desc_id' => 'xsd:int',
261
+        'course_desc_title' => 'xsd:string',
262
+        'course_desc_content' => 'xsd:string'
263
+    )
264 264
 );
265 265
 
Please login to merge, or discard this patch.
main/webservices/soap_report.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 $s = WSSoapServer::singleton();
10 10
 
11 11
 $s->wsdl->addComplexType(
12
-	'user_id',
13
-	'complexType',
14
-	'struct',
15
-	'all',
16
-	'',
17
-	array(
18
-		'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
19
-		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string')
20
-	)
12
+    'user_id',
13
+    'complexType',
14
+    'struct',
15
+    'all',
16
+    '',
17
+    array(
18
+        'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
19
+        'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string')
20
+    )
21 21
 );
22 22
 
23 23
 $s->wsdl->addComplexType(
@@ -59,52 +59,52 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
 $s->wsdl->addComplexType(
62
-	'user_result',
63
-	'complexType',
64
-	'struct',
65
-	'all',
66
-	'',
67
-	array(
68
-		'id' => array('name' => 'id', 'type' => 'xsd:string'),
69
-		'title' => array('name' => 'title', 'type' => 'xsd:string')
70
-	)
62
+    'user_result',
63
+    'complexType',
64
+    'struct',
65
+    'all',
66
+    '',
67
+    array(
68
+        'id' => array('name' => 'id', 'type' => 'xsd:string'),
69
+        'title' => array('name' => 'title', 'type' => 'xsd:string')
70
+    )
71 71
 );
72 72
 
73 73
 $s->wsdl->addComplexType(
74
-  'progress_result',
75
-	'complexType',
76
-	'struct',
77
-	'all',
78
-	'',
79
-	array(
80
-		'progress_bar_mode' => array('name' => 'progress_bar_mode', 'type' => 'xsd:string'),
81
-		'progress_db' => array('name' => 'progress_db', 'type' => 'xsd:string')
82
-	)
74
+    'progress_result',
75
+    'complexType',
76
+    'struct',
77
+    'all',
78
+    '',
79
+    array(
80
+        'progress_bar_mode' => array('name' => 'progress_bar_mode', 'type' => 'xsd:string'),
81
+        'progress_db' => array('name' => 'progress_db', 'type' => 'xsd:string')
82
+    )
83 83
 );
84 84
 
85 85
 $s->wsdl->addComplexType(
86
-  'score_result',
87
-	'complexType',
88
-	'struct',
89
-	'all',
90
-	'',
91
-	array(
92
-		'min_score' => array('name' => 'min_score', 'type' => 'xsd:string'),
93
-		'max_score' => array('name' => 'max_score', 'type' => 'xsd:string'),
86
+    'score_result',
87
+    'complexType',
88
+    'struct',
89
+    'all',
90
+    '',
91
+    array(
92
+        'min_score' => array('name' => 'min_score', 'type' => 'xsd:string'),
93
+        'max_score' => array('name' => 'max_score', 'type' => 'xsd:string'),
94 94
     'mastery_score' => array('name' => 'mastery_score', 'type' => 'xsd:string'),
95 95
     'current_score' => array('name' => 'current_score', 'type' => 'xsd:string'),
96
-	)
96
+    )
97 97
 );
98 98
 
99 99
 $s->wsdl->addComplexType(
100
-	'user_result_array',
101
-	'complexType',
102
-	'array',
103
-	'',
104
-	'SOAP-ENC:Array',
105
-	array(),
106
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_result[]')),
107
-	'tns:user_result'
100
+    'user_result_array',
101
+    'complexType',
102
+    'array',
103
+    '',
104
+    'SOAP-ENC:Array',
105
+    array(),
106
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_result[]')),
107
+    'tns:user_result'
108 108
 );
109 109
 
110 110
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 $s->register(
119 119
     'WSReport.GetTimeSpentOnCourse',
120 120
     array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string'),
121
-	array('return' => 'xsd:string')
121
+    array('return' => 'xsd:string')
122 122
 );
123 123
 
124 124
 $s->register(
@@ -166,5 +166,5 @@  discard block
 block discarded – undo
166 166
 $s->register(
167 167
     'WSReport.test',
168 168
     array(),
169
-	array('return' => 'xsd:string')
169
+    array('return' => 'xsd:string')
170 170
 );
Please login to merge, or discard this patch.
main/webservices/cm_soap.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,83 +8,83 @@  discard block
 block discarded – undo
8 8
  * SOAP error handler. Handles an error sending a SOAP fault
9 9
  */
10 10
 class WSCMSoapErrorHandler implements WSCMErrorHandler {
11
-	/**
12
-	 * Handles the error by sending a SOAP fault through the server
13
-	 *
14
-	 * @param WSError Error to handle
15
-	 */
16
-	public function handle($error) {
17
-		$server = WSCMSoapServer::singleton();
18
-		$server->fault(strval($error->code), $error->message);
19
-	}
11
+    /**
12
+     * Handles the error by sending a SOAP fault through the server
13
+     *
14
+     * @param WSError Error to handle
15
+     */
16
+    public function handle($error) {
17
+        $server = WSCMSoapServer::singleton();
18
+        $server->fault(strval($error->code), $error->message);
19
+    }
20 20
 }
21 21
 
22 22
 /**
23 23
  * SOAP server wrapper implementing a Singleton
24 24
  */
25 25
 class WSCMSoapServer {
26
-	/**
27
-	 * SOAP server instance
28
-	 *
29
-	 * @var soap_server
30
-	 */
31
-	private static $_instance;
26
+    /**
27
+     * SOAP server instance
28
+     *
29
+     * @var soap_server
30
+     */
31
+    private static $_instance;
32 32
 
33
-	/**
34
-	 * Private constructor
35
-	 */
36
-	private function __construct() {
37
-	}
33
+    /**
34
+     * Private constructor
35
+     */
36
+    private function __construct() {
37
+    }
38 38
 
39
-	/**
40
-	 * Singleton method
41
-	 */
42
-	public static function singleton() {
43
-		if(!isset(self::$_instance)) {
44
-			self::$_instance = new soap_server();
45
-			// Set the error handler
46
-			WSCMError::setErrorHandler(new WSCMSoapErrorHandler());
47
-			// Configure the service
48
-			self::$_instance->configureWSDL('WSCMService', 'urn:WSCMService');
49
-		}
39
+    /**
40
+     * Singleton method
41
+     */
42
+    public static function singleton() {
43
+        if(!isset(self::$_instance)) {
44
+            self::$_instance = new soap_server();
45
+            // Set the error handler
46
+            WSCMError::setErrorHandler(new WSCMSoapErrorHandler());
47
+            // Configure the service
48
+            self::$_instance->configureWSDL('WSCMService', 'urn:WSCMService');
49
+        }
50 50
 
51
-		return self::$_instance;
52
-	}
51
+        return self::$_instance;
52
+    }
53 53
 }
54 54
 
55 55
 $s = WSCMSoapServer::singleton();
56 56
 
57 57
 $s->wsdl->addComplexType(
58
-	'result',
59
-	'complexType',
60
-	'struct',
61
-	'all',
62
-	'',
63
-	array(
64
-		'code' => array('name' => 'code', 'type' => 'xsd:int'),
65
-		'message' => array('name' => 'message', 'type' => 'xsd:string')
66
-	)
58
+    'result',
59
+    'complexType',
60
+    'struct',
61
+    'all',
62
+    '',
63
+    array(
64
+        'code' => array('name' => 'code', 'type' => 'xsd:int'),
65
+        'message' => array('name' => 'message', 'type' => 'xsd:string')
66
+    )
67 67
 );
68 68
 
69 69
 $s->wsdl->addComplexType(
70
-	'extra_field',
71
-	'complexType',
72
-	'struct',
73
-	'all',
74
-	'',
75
-	array(
76
-		'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
77
-		'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
78
-	)
70
+    'extra_field',
71
+    'complexType',
72
+    'struct',
73
+    'all',
74
+    '',
75
+    array(
76
+        'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
77
+        'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
78
+    )
79 79
 );
80 80
 
81 81
 $s->register(
82
-	'WSCM.verifyUserPass',
83
-	array(
84
-		'username' => 'xsd:string',
85
-		'password' => 'xsd:string',
86
-	),
87
-	array('return' => 'xsd:string')
82
+    'WSCM.verifyUserPass',
83
+    array(
84
+        'username' => 'xsd:string',
85
+        'password' => 'xsd:string',
86
+    ),
87
+    array('return' => 'xsd:string')
88 88
 );
89 89
 
90 90
 $s->register(
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 );
95 95
 
96 96
 $s->register(
97
-	'WSCM.test',
98
-	array(),
99
-	array('return' => 'xsd:string'),
97
+    'WSCM.test',
98
+    array(),
99
+    array('return' => 'xsd:string'),
100 100
         'urn:WSCMService',
101 101
         '',
102 102
         '',
Please login to merge, or discard this patch.
main/webservices/webservice_user.php 1 patch
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -11,458 +11,458 @@
 block discarded – undo
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
         global $api_failureList;
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) {
236
-			$failure = $api_failureList[0];
237
-			if($failure == 'login-pass already taken') {
238
-				return new WSError(102, 'This username is already taken');
239
-			} else if($failure == 'encrypt_method invalid') {
240
-				return new WSError(103, 'The encryption of the password is invalid');
241
-			} else {
242
-				return new WSError(104, 'There was an error creating the user');
243
-			}
244
-		} else {
245
-			return $result;
246
-		}
247
-	}
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
+            $failure = $api_failureList[0];
237
+            if($failure == 'login-pass already taken') {
238
+                return new WSError(102, 'This username is already taken');
239
+            } else if($failure == 'encrypt_method invalid') {
240
+                return new WSError(103, 'The encryption of the password is invalid');
241
+            } else {
242
+                return new WSError(104, 'There was an error creating the user');
243
+            }
244
+        } else {
245
+            return $result;
246
+        }
247
+    }
248 248
 
249
-	/**
250
-	 * Creates a user
251
-	 *
252
-	 * @param string API secret key
253
-	 * @param string User first name
254
-	 * @param string User last name
255
-	 * @param int User status
256
-	 * @param string Login name
257
-	 * @param string Password (encrypted or not)
258
-	 * @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
259
-	 * to include the salt in the extra fields if you are encrypting the password
260
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
-	 * @param string User id value. Leave blank if you are using the internal user_id
262
-	 * @param int Visibility. Set by default to 1
263
-	 * @param string User email. Set by default to an empty string
264
-	 * @param string Language. Set by default to english
265
-	 * @param string Phone. Set by default to an empty string
266
-	 * @param string Expiration date. Set to null by default
267
-	 * @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
268
-	 * @return int New user id generated by the system
269
-	 */
270
-	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()) {
271
-		// First, verify the secret key
272
-		$verifKey = $this->verifyKey($secret_key);
273
-		if($verifKey instanceof WSError) {
274
-			$this->handleError($verifKey);
275
-		} else {
276
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
-			if($result instanceof WSError) {
278
-				$this->handleError($result);
279
-			} else {
280
-				return $result;
281
-			}
282
-		}
283
-	}
249
+    /**
250
+     * Creates a user
251
+     *
252
+     * @param string API secret key
253
+     * @param string User first name
254
+     * @param string User last name
255
+     * @param int User status
256
+     * @param string Login name
257
+     * @param string Password (encrypted or not)
258
+     * @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
259
+     * to include the salt in the extra fields if you are encrypting the password
260
+     * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
261
+     * @param string User id value. Leave blank if you are using the internal user_id
262
+     * @param int Visibility. Set by default to 1
263
+     * @param string User email. Set by default to an empty string
264
+     * @param string Language. Set by default to english
265
+     * @param string Phone. Set by default to an empty string
266
+     * @param string Expiration date. Set to null by default
267
+     * @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
268
+     * @return int New user id generated by the system
269
+     */
270
+    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()) {
271
+        // First, verify the secret key
272
+        $verifKey = $this->verifyKey($secret_key);
273
+        if($verifKey instanceof WSError) {
274
+            $this->handleError($verifKey);
275
+        } else {
276
+            $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
277
+            if($result instanceof WSError) {
278
+                $this->handleError($result);
279
+            } else {
280
+                return $result;
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Creates multiple users
287
-	 *
288
-	 * @param string API secret key
289
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
-	 * @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'))
291
-	 */
292
-	public function CreateUsers($secret_key, $users) {
293
-		$verifKey = $this->verifyKey($secret_key);
294
-		if($verifKey instanceof WSError) {
295
-			$this->handleError($verifKey);
296
-		} else {
297
-			$results = array();
298
-			foreach($users as $user) {
299
-				$result_tmp = array();
285
+    /**
286
+     * Creates multiple users
287
+     *
288
+     * @param string API secret key
289
+     * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
290
+     * @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'))
291
+     */
292
+    public function CreateUsers($secret_key, $users) {
293
+        $verifKey = $this->verifyKey($secret_key);
294
+        if($verifKey instanceof WSError) {
295
+            $this->handleError($verifKey);
296
+        } else {
297
+            $results = array();
298
+            foreach($users as $user) {
299
+                $result_tmp = array();
300 300
                 // re-initialize variables just in case
301 301
                 $firstname = $lastname = $status = $login = $password = $encrypt_method = $user_id_field_name = $user_id_value = $visibility = $email = $language = $phone = $expiration_date = $extras = null;
302
-				extract($user);
303
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
-				if($result instanceof WSError) {
305
-					$result_tmp['result'] = $result->toArray();
306
-					$result_tmp['user_id_value'] = $user_id_value;
307
-					$result_tmp['user_id_generated'] = 0;
308
-				} else {
309
-					$result_tmp['result'] = $this->getSuccessfulResult();
310
-					$result_tmp['user_id_value'] = $user_id_value;
311
-					$result_tmp['user_id_generated'] = $result;
312
-				}
313
-				$results[] = $result_tmp;
314
-			}
315
-			return $results;
316
-		}
317
-	}
302
+                extract($user);
303
+                $result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
304
+                if($result instanceof WSError) {
305
+                    $result_tmp['result'] = $result->toArray();
306
+                    $result_tmp['user_id_value'] = $user_id_value;
307
+                    $result_tmp['user_id_generated'] = 0;
308
+                } else {
309
+                    $result_tmp['result'] = $this->getSuccessfulResult();
310
+                    $result_tmp['user_id_value'] = $user_id_value;
311
+                    $result_tmp['user_id_generated'] = $result;
312
+                }
313
+                $results[] = $result_tmp;
314
+            }
315
+            return $results;
316
+        }
317
+    }
318 318
 
319
-	/**
320
-	 * Edits user info (helper method)
321
-	 *
322
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
-	 * @param string User id value
324
-	 * @param string First name
325
-	 * @param string Last name
326
-	 * @param int User status
327
-	 * @param string Login name
328
-	 * @param string Password. Leave blank if you don't want to update it
329
-	 * @param string Encrypt method
330
-	 * @param string User email
331
-	 * @param string Language. Set by default to english
332
-	 * @param string Phone. Set by default to an empty string
333
-	 * @param string Expiration date. Set to null by default
334
-	 * @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
335
-	 * @return mixed True if user was successfully updated, WSError otherwise
336
-	 */
337
-	protected function editUserHelper(
338
-		$user_id_field_name,
339
-		$user_id_value,
340
-		$firstname,
341
-		$lastname,
342
-		$status,
343
-		$loginname,
344
-		$password,
345
-		$encrypt_method,
346
-		$email,
347
-		$language,
348
-		$phone,
349
-		$expiration_date,
350
-		$extras
351
-	) {
319
+    /**
320
+     * Edits user info (helper method)
321
+     *
322
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
323
+     * @param string User id value
324
+     * @param string First name
325
+     * @param string Last name
326
+     * @param int User status
327
+     * @param string Login name
328
+     * @param string Password. Leave blank if you don't want to update it
329
+     * @param string Encrypt method
330
+     * @param string User email
331
+     * @param string Language. Set by default to english
332
+     * @param string Phone. Set by default to an empty string
333
+     * @param string Expiration date. Set to null by default
334
+     * @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
335
+     * @return mixed True if user was successfully updated, WSError otherwise
336
+     */
337
+    protected function editUserHelper(
338
+        $user_id_field_name,
339
+        $user_id_value,
340
+        $firstname,
341
+        $lastname,
342
+        $status,
343
+        $loginname,
344
+        $password,
345
+        $encrypt_method,
346
+        $email,
347
+        $language,
348
+        $phone,
349
+        $expiration_date,
350
+        $extras
351
+    ) {
352 352
         global $api_failureList;
353
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
-		if($user_id instanceof WSError) {
355
-			return $user_id;
356
-		} else {
357
-			if($password == '') {
358
-				$password = null;
359
-			}
360
-			$user_info = api_get_user_info($user_id);
361
-			if (count($extras) == 0) {
362
-				$extras = null;
363
-			}
353
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
354
+        if($user_id instanceof WSError) {
355
+            return $user_id;
356
+        } else {
357
+            if($password == '') {
358
+                $password = null;
359
+            }
360
+            $user_info = api_get_user_info($user_id);
361
+            if (count($extras) == 0) {
362
+                $extras = null;
363
+            }
364 364
 
365
-			$result = UserManager::update_user(
366
-				$user_id,
367
-				$firstname,
368
-				$lastname,
369
-				$loginname,
370
-				$password,
371
-				PLATFORM_AUTH_SOURCE,
372
-				$email,
373
-				$status,
374
-				'',
375
-				$phone,
376
-				$user_info['picture_uri'],
377
-				$expiration_date,
378
-				$user_info['active'],
379
-				null,
380
-				$user_info['hr_dept_id'],
381
-				$extras,
382
-				$encrypt_method
383
-			);
384
-			if (!$result) {
385
-				$failure = $api_failureList[0];
386
-				if($failure == 'encrypt_method invalid') {
387
-					return new WSError(103, 'The encryption of the password is invalid');
388
-				} else {
389
-					return new WSError(105, 'There was an error updating the user');
390
-				}
391
-			} else {
392
-				return $result;
393
-			}
394
-		}
395
-	}
365
+            $result = UserManager::update_user(
366
+                $user_id,
367
+                $firstname,
368
+                $lastname,
369
+                $loginname,
370
+                $password,
371
+                PLATFORM_AUTH_SOURCE,
372
+                $email,
373
+                $status,
374
+                '',
375
+                $phone,
376
+                $user_info['picture_uri'],
377
+                $expiration_date,
378
+                $user_info['active'],
379
+                null,
380
+                $user_info['hr_dept_id'],
381
+                $extras,
382
+                $encrypt_method
383
+            );
384
+            if (!$result) {
385
+                $failure = $api_failureList[0];
386
+                if($failure == 'encrypt_method invalid') {
387
+                    return new WSError(103, 'The encryption of the password is invalid');
388
+                } else {
389
+                    return new WSError(105, 'There was an error updating the user');
390
+                }
391
+            } else {
392
+                return $result;
393
+            }
394
+        }
395
+    }
396 396
 
397
-	/**
398
-	 * Edits user info
399
-	 *
400
-	 * @param string API secret key
401
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
-	 * @param string User id value
403
-	 * @param string First name
404
-	 * @param string Last name
405
-	 * @param int User status
406
-	 * @param string Login name
407
-	 * @param string Password. Leave blank if you don't want to update it
408
-	 * @param string Encrypt method
409
-	 * @param string User email
410
-	 * @param string Language. Set by default to english
411
-	 * @param string Phone. Set by default to an empty string
412
-	 * @param string Expiration date. Set to null by default
413
-	 * @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
414
-	 */
415
-	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) {
416
-		// First, verify the secret key
417
-		$verifKey = $this->verifyKey($secret_key);
418
-		if($verifKey instanceof WSError) {
419
-			$this->handleError($verifKey);
420
-		} else {
397
+    /**
398
+     * Edits user info
399
+     *
400
+     * @param string API secret key
401
+     * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
402
+     * @param string User id value
403
+     * @param string First name
404
+     * @param string Last name
405
+     * @param int User status
406
+     * @param string Login name
407
+     * @param string Password. Leave blank if you don't want to update it
408
+     * @param string Encrypt method
409
+     * @param string User email
410
+     * @param string Language. Set by default to english
411
+     * @param string Phone. Set by default to an empty string
412
+     * @param string Expiration date. Set to null by default
413
+     * @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
414
+     */
415
+    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) {
416
+        // First, verify the secret key
417
+        $verifKey = $this->verifyKey($secret_key);
418
+        if($verifKey instanceof WSError) {
419
+            $this->handleError($verifKey);
420
+        } else {
421 421
 
422
-			$extras_associative = array();
423
-			if (!empty($extras)) {
424
-				foreach($extras as $extra) {
425
-					$extras_associative[$extra['field_name']] = $extra['field_value'];
426
-				}
427
-			}
422
+            $extras_associative = array();
423
+            if (!empty($extras)) {
424
+                foreach($extras as $extra) {
425
+                    $extras_associative[$extra['field_name']] = $extra['field_value'];
426
+                }
427
+            }
428 428
 
429
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
-			if($result instanceof WSError) {
431
-				$this->handleError($result);
432
-			}
433
-		}
434
-	}
429
+            $result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras_associative);
430
+            if($result instanceof WSError) {
431
+                $this->handleError($result);
432
+            }
433
+        }
434
+    }
435 435
 
436
-	/**
437
-	 * Edits multiple users
438
-	 *
439
-	 * @param string API secret key
440
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
-	 * @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
442
-	 * than 0, an error occured
443
-	 */
444
-	public function EditUsers($secret_key, $users) {
445
-		$verifKey = $this->verifyKey($secret_key);
446
-		if($verifKey instanceof WSError) {
447
-			$this->handleError($verifKey);
448
-		} else {
449
-			$results = array();
450
-			foreach($users as $user) {
451
-				$result_tmp = array();
436
+    /**
437
+     * Edits multiple users
438
+     *
439
+     * @param string API secret key
440
+     * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
441
+     * @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
442
+     * than 0, an error occured
443
+     */
444
+    public function EditUsers($secret_key, $users) {
445
+        $verifKey = $this->verifyKey($secret_key);
446
+        if($verifKey instanceof WSError) {
447
+            $this->handleError($verifKey);
448
+        } else {
449
+            $results = array();
450
+            foreach($users as $user) {
451
+                $result_tmp = array();
452 452
                 // re-initialize variables just in case
453 453
                 $user_id_field_name = $user_id_value = $firstname = $lastname = $status = $loginname = $password = $encrypt_method = $email = $language = $phone = $expiration_date = $extras = null;
454
-				extract($user);
455
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
-				$result_tmp['user_id_value'] = $user['user_id_value'];
457
-				if($result_op instanceof WSError) {
458
-					// Return the error in the results
459
-					$result_tmp['result'] = $result_op->toArray();
460
-				} else {
461
-					$result_tmp['result'] = $this->getSuccessfulResult();
462
-				}
463
-				$results[] = $result_tmp;
464
-			}
465
-			return $results;
466
-		}
467
-	}
454
+                extract($user);
455
+                $result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
456
+                $result_tmp['user_id_value'] = $user['user_id_value'];
457
+                if($result_op instanceof WSError) {
458
+                    // Return the error in the results
459
+                    $result_tmp['result'] = $result_op->toArray();
460
+                } else {
461
+                    $result_tmp['result'] = $this->getSuccessfulResult();
462
+                }
463
+                $results[] = $result_tmp;
464
+            }
465
+            return $results;
466
+        }
467
+    }
468 468
 }
Please login to merge, or discard this patch.
main/webservices/cm_soap_announcements.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 
12 12
 
13 13
 $s->register(
14
-	'WSCMAnnouncements.get_announcements_id',
15
-	array(
16
-		'username' => 'xsd:string',
17
-		'password' => 'xsd:string',
14
+    'WSCMAnnouncements.get_announcements_id',
15
+    array(
16
+        'username' => 'xsd:string',
17
+        'password' => 'xsd:string',
18 18
                 'course_code' => 'xsd:string'
19
-	),
20
-	array('return' => 'xsd:string'),
19
+    ),
20
+    array('return' => 'xsd:string'),
21 21
         'urn:WSCMService',
22 22
         '',
23 23
         '',
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 );
28 28
 
29 29
 $s->register(
30
-	'WSCMAnnouncements.get_announcement_data',
31
-	array(
32
-		'username' => 'xsd:string',
33
-		'password' => 'xsd:string',
30
+    'WSCMAnnouncements.get_announcement_data',
31
+    array(
32
+        'username' => 'xsd:string',
33
+        'password' => 'xsd:string',
34 34
                 'course_code' => 'xsd:string',
35 35
                 'announcement_id' => 'xsd:string',
36 36
                 'field' => 'xsd:string'
37
-	),
38
-	array('return' => 'xsd:string'),
37
+    ),
38
+    array('return' => 'xsd:string'),
39 39
         'urn:WSCMService',
40 40
         '',
41 41
         '',
Please login to merge, or discard this patch.
main/webservices/cm_soap_inbox.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
 
13 13
 $s->register(
14
-	'WSCMInbox.unreadMessage',
15
-	array(
16
-		'username' => 'xsd:string',
17
-		'password' => 'xsd:string',
18
-	),
19
-	array('return' => 'xsd:string'),
14
+    'WSCMInbox.unreadMessage',
15
+    array(
16
+        'username' => 'xsd:string',
17
+        'password' => 'xsd:string',
18
+    ),
19
+    array('return' => 'xsd:string'),
20 20
         'urn:WSCMService',
21 21
         '',
22 22
         '',
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 );
27 27
 
28 28
 $s->register(
29
-	'WSCMInbox.get_message_id',
30
-	array(
31
-		'username' => 'xsd:string',
32
-		'password' => 'xsd:string',
29
+    'WSCMInbox.get_message_id',
30
+    array(
31
+        'username' => 'xsd:string',
32
+        'password' => 'xsd:string',
33 33
                 'from' => 'xsd:string',
34 34
                 'number_of_items' => 'xsd:string'
35
-	),
36
-	array('return' => 'xsd:string'),
35
+    ),
36
+    array('return' => 'xsd:string'),
37 37
         'urn:WSCMService',
38 38
         '',
39 39
         '',
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 $s->register(
47
-	'WSCMInbox.get_message_data',
48
-	array(
49
-		'username' => 'xsd:string',
50
-		'password' => 'xsd:string',
47
+    'WSCMInbox.get_message_data',
48
+    array(
49
+        'username' => 'xsd:string',
50
+        'password' => 'xsd:string',
51 51
                 'id' => 'xsd:string',
52 52
                 'field' => 'xsd:string'
53
-	),
54
-	array('return' => 'xsd:string'),
53
+    ),
54
+    array('return' => 'xsd:string'),
55 55
         'urn:WSCMService',
56 56
         '',
57 57
         '',
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 );
62 62
 
63 63
 $s->register(
64
-	'WSCMInbox.get_message_id_sent',
65
-	array(
66
-		'username' => 'xsd:string',
67
-		'password' => 'xsd:string',
64
+    'WSCMInbox.get_message_id_sent',
65
+    array(
66
+        'username' => 'xsd:string',
67
+        'password' => 'xsd:string',
68 68
                 'from' => 'xsd:string',
69 69
                 'number_of_items' => 'xsd:string'
70
-	),
71
-	array('return' => 'xsd:string'),
70
+    ),
71
+    array('return' => 'xsd:string'),
72 72
         'urn:WSCMService',
73 73
         '',
74 74
         '',
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 );
79 79
 
80 80
 $s->register(
81
-	'WSCMInbox.get_message_data_sent',
82
-	array(
83
-		'username' => 'xsd:string',
84
-		'password' => 'xsd:string',
81
+    'WSCMInbox.get_message_data_sent',
82
+    array(
83
+        'username' => 'xsd:string',
84
+        'password' => 'xsd:string',
85 85
                 'id' => 'xsd:string',
86 86
                 'field' => 'xsd:string'
87
-	),
88
-	array('return' => 'xsd:string'),
87
+    ),
88
+    array('return' => 'xsd:string'),
89 89
         'urn:WSCMService',
90 90
         '',
91 91
         '',
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 );
96 96
 
97 97
 $s->register(
98
-	'WSCMInbox.message_send',
99
-	array(
100
-		'username' => 'xsd:string',
101
-		'password' => 'xsd:string',
98
+    'WSCMInbox.message_send',
99
+    array(
100
+        'username' => 'xsd:string',
101
+        'password' => 'xsd:string',
102 102
                 'receiver_user_id' => 'xsd:string',
103 103
                 'subject' => 'xsd:string',
104 104
                 'content' => 'xsd:string'
105
-	),
106
-	array('return' => 'xsd:string'),
105
+    ),
106
+    array('return' => 'xsd:string'),
107 107
         'urn:WSCMService',
108 108
         '',
109 109
         '',
Please login to merge, or discard this patch.
main/webservices/http-auth.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 $validResponse = md5("{$A1}:{$digestParts['nonce']}:{$digestParts['nc']}:{$digestParts['cnonce']}:{$digestParts['qop']}:{$A2}");
27 27
 
28 28
 if ($digestParts['response'] != $validResponse)
29
-  requireLogin($realm,$nonce);
29
+    requireLogin($realm,$nonce);
30 30
 else {
31
-  // We're in!
32
-  echo 'a7532ae474e5e66a0c16eddab02e02a7';
33
-  die();
31
+    // We're in!
32
+    echo 'a7532ae474e5e66a0c16eddab02e02a7';
33
+    die();
34 34
 }
35 35
 
36 36
 // This function returns the digest string
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     // most other servers
43 43
     }
44 44
     elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) {
45
-      if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']),'digest')===0)
45
+        if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']),'digest')===0)
46 46
         $digest = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
47 47
     }
48 48
     elseif (isset($_SERVER['HTTP_WWW_AUTHENTICATE'])) {
49
-      $digest = $_SERVER['HTTP_WWW_AUTHENTICATE'];
49
+        $digest = $_SERVER['HTTP_WWW_AUTHENTICATE'];
50 50
     }
51 51
     return $digest;
52 52
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 1 patch
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -6,120 +6,120 @@  discard block
 block discarded – undo
6 6
  * Error returned by one of the methods of the web service. Contains an error code and an error message
7 7
  */
8 8
 class WSCMError {
9
-	/**
10
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
-	 *
12
-	 * @var WSErrorHandler
13
-	 */
14
-	protected static $_handler;
9
+    /**
10
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
+     *
12
+     * @var WSErrorHandler
13
+     */
14
+    protected static $_handler;
15 15
 
16
-	/**
17
-	 * Error code
18
-	 *
19
-	 * @var int
20
-	 */
21
-	public $code;
16
+    /**
17
+     * Error code
18
+     *
19
+     * @var int
20
+     */
21
+    public $code;
22 22
 
23
-	/**
24
-	 * Error message
25
-	 *
26
-	 * @var string
27
-	 */
28
-	public $message;
23
+    /**
24
+     * Error message
25
+     *
26
+     * @var string
27
+     */
28
+    public $message;
29 29
 
30
-	/**
31
-	 * Constructor
32
-	 *
33
-	 * @param int Error code
34
-	 * @param string Error message
35
-	 */
36
-	public function __construct($code, $message) {
37
-		$this->code = $code;
38
-		$this->message = $message;
39
-	}
30
+    /**
31
+     * Constructor
32
+     *
33
+     * @param int Error code
34
+     * @param string Error message
35
+     */
36
+    public function __construct($code, $message) {
37
+        $this->code = $code;
38
+        $this->message = $message;
39
+    }
40 40
 
41
-	/**
42
-	 * Sets the error handler
43
-	 *
44
-	 * @param WSErrorHandler Error handler
45
-	 */
46
-	public static function setErrorHandler($handler) {
47
-		if($handler instanceof WSErrorHandler) {
48
-			self::$_handler = $handler;
49
-		}
50
-	}
41
+    /**
42
+     * Sets the error handler
43
+     *
44
+     * @param WSErrorHandler Error handler
45
+     */
46
+    public static function setErrorHandler($handler) {
47
+        if($handler instanceof WSErrorHandler) {
48
+            self::$_handler = $handler;
49
+        }
50
+    }
51 51
 
52
-	/**
53
-	 * Returns the error handler
54
-	 *
55
-	 * @return WSErrorHandler Error handler
56
-	 */
57
-	public static function getErrorHandler() {
58
-		return self::$_handler;
59
-	}
52
+    /**
53
+     * Returns the error handler
54
+     *
55
+     * @return WSErrorHandler Error handler
56
+     */
57
+    public static function getErrorHandler() {
58
+        return self::$_handler;
59
+    }
60 60
 
61
-	/**
62
-	 * Transforms the error into an array
63
-	 *
64
-	 * @return array Associative array with code and message
65
-	 */
66
-	public function toArray() {
67
-		return array('code' => $this->code, 'message' => $this->message);
68
-	}
61
+    /**
62
+     * Transforms the error into an array
63
+     *
64
+     * @return array Associative array with code and message
65
+     */
66
+    public function toArray() {
67
+        return array('code' => $this->code, 'message' => $this->message);
68
+    }
69 69
 }
70 70
 
71 71
 /**
72 72
  * Interface that must be implemented by any error handler
73 73
  */
74 74
 interface WSCMErrorHandler {
75
-	/**
76
-	 * Handle method
77
-	 *
78
-	 * @param WSError Error
79
-	 */
80
-	public function handle($error);
75
+    /**
76
+     * Handle method
77
+     *
78
+     * @param WSError Error
79
+     */
80
+    public function handle($error);
81 81
 }
82 82
 
83 83
 /**
84 84
  * Main class of the webservice. Webservice classes extend this class
85 85
  */
86 86
 class WSCM {
87
-	/**
88
-	 * Chamilo configuration
89
-	 *
90
-	 * @var array
91
-	 */
92
-	protected $_configuration;
87
+    /**
88
+     * Chamilo configuration
89
+     *
90
+     * @var array
91
+     */
92
+    protected $_configuration;
93 93
 
94
-	/**
95
-	 * Constructor
96
-	 */
97
-	public function __construct() {
98
-		$this->_configuration = $GLOBALS['_configuration'];
99
-	}
94
+    /**
95
+     * Constructor
96
+     */
97
+    public function __construct() {
98
+        $this->_configuration = $GLOBALS['_configuration'];
99
+    }
100 100
 
101
-	/**
102
-	 * Verifies the API key
103
-	 *
104
-	 * @param string Secret key
105
-	 * @return mixed WSError in case of failure, null in case of success
106
-	 */
107
-	protected function verifyKey($secret_key) {
108
-		$ip = trim($_SERVER['REMOTE_ADDR']);
109
-		// if we are behind a reverse proxy, assume it will send the
110
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
111
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
-		  $ip = trim($ip1);
114
-		}
115
-		$security_key = $ip.$this->_configuration['security_key'];
101
+    /**
102
+     * Verifies the API key
103
+     *
104
+     * @param string Secret key
105
+     * @return mixed WSError in case of failure, null in case of success
106
+     */
107
+    protected function verifyKey($secret_key) {
108
+        $ip = trim($_SERVER['REMOTE_ADDR']);
109
+        // if we are behind a reverse proxy, assume it will send the
110
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
111
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
+            list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
+            $ip = trim($ip1);
114
+        }
115
+        $security_key = $ip.$this->_configuration['security_key'];
116 116
 
117
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
-			return new WSCMError(1, "API key is invalid");
119
-		} else {
120
-			return null;
121
-		}
122
-	}
117
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
+            return new WSCMError(1, "API key is invalid");
119
+        } else {
120
+            return null;
121
+        }
122
+    }
123 123
 
124 124
         /**
125 125
          * Verifies if the user is valid
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
             $login = $username;
135 135
             $password = $pass;
136 136
 
137
-	    //lookup the user in the main database
137
+        //lookup the user in the main database
138 138
             $user_table = Database::get_main_table(TABLE_MAIN_USER);
139
-	    $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
139
+        $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
140 140
 	            FROM $user_table
141 141
 	            WHERE username = '".trim(addslashes($login))."'";
142
-	    $result = Database::query($sql);
142
+        $result = Database::query($sql);
143 143
 
144 144
             if (Database::num_rows($result) > 0) {
145 145
                 $uData = Database::fetch_array($result);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         /**
173 173
          * Return the encrypted pass
174
-		 * @deprecated
174
+         * @deprecated
175 175
          * @param <String> $pass
176 176
          * @return <String> $pass encrypted
177 177
          */
@@ -180,112 +180,112 @@  discard block
 block discarded – undo
180 180
         }*/
181 181
 
182 182
         /**
183
-	 * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
-	 * in the system database
185
-	 *
186
-	 * @param string User id field name
187
-	 * @param string User id value
188
-	 * @return mixed System user id if the user was found, WSError otherwise
189
-	 */
190
-	protected function getUserId($user_id_field_name, $user_id_value) {
191
-		if($user_id_field_name == "chamilo_user_id") {
192
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
-				return intval($user_id_value);
194
-			} else {
195
-				return new WSCMError(100, "User not found");
196
-			}
197
-		} else {
198
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
-			if($user_id == 0) {
200
-				return new WSCMError(100, "User not found");
201
-			} else {
202
-				return $user_id;
203
-			}
204
-		}
205
-	}
183
+         * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
+         * in the system database
185
+         *
186
+         * @param string User id field name
187
+         * @param string User id value
188
+         * @return mixed System user id if the user was found, WSError otherwise
189
+         */
190
+    protected function getUserId($user_id_field_name, $user_id_value) {
191
+        if($user_id_field_name == "chamilo_user_id") {
192
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
+                return intval($user_id_value);
194
+            } else {
195
+                return new WSCMError(100, "User not found");
196
+            }
197
+        } else {
198
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
+            if($user_id == 0) {
200
+                return new WSCMError(100, "User not found");
201
+            } else {
202
+                return $user_id;
203
+            }
204
+        }
205
+    }
206 206
 
207
-	/**
208
-	 * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
-	 * in the system database
210
-	 *
211
-	 * @param string Course id field name
212
-	 * @param string Course id value
213
-	 * @return mixed System course id if the course was found, WSError otherwise
214
-	 */
215
-	protected function getCourseId($course_id_field_name, $course_id_value) {
216
-		if($course_id_field_name == "chamilo_course_id") {
217
-			if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
-				return intval($course_id_value);
219
-			} else {
220
-				return new WSCMError(200, "Course not found");
221
-			}
222
-		} else {
223
-			$courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
-			if (empty($courseId)) {
225
-				return new WSCMError(200, "Course not found");
226
-			} else {
227
-				return $courseId;
228
-			}
229
-		}
230
-	}
207
+    /**
208
+     * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
+     * in the system database
210
+     *
211
+     * @param string Course id field name
212
+     * @param string Course id value
213
+     * @return mixed System course id if the course was found, WSError otherwise
214
+     */
215
+    protected function getCourseId($course_id_field_name, $course_id_value) {
216
+        if($course_id_field_name == "chamilo_course_id") {
217
+            if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
+                return intval($course_id_value);
219
+            } else {
220
+                return new WSCMError(200, "Course not found");
221
+            }
222
+        } else {
223
+            $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
+            if (empty($courseId)) {
225
+                return new WSCMError(200, "Course not found");
226
+            } else {
227
+                return $courseId;
228
+            }
229
+        }
230
+    }
231 231
 
232
-	/**
233
-	 * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
-	 * in the system database
235
-	 *
236
-	 * @param string Session id field name
237
-	 * @param string Session id value
238
-	 * @return mixed System session id if the session was found, WSError otherwise
239
-	 */
240
-	protected function getSessionId($session_id_field_name, $session_id_value)
241
-	{
242
-		if ($session_id_field_name == "chamilo_session_id") {
243
-			$session = SessionManager::fetch((int)$session_id_value);
244
-			if(!empty($session)) {
245
-				return intval($session_id_value);
246
-			} else {
247
-				return new WSCMError(300, "Session not found");
248
-			}
249
-		} else {
250
-			$session_id = SessionManager::getSessionIdFromOriginalId(
251
-				$session_id_value,
252
-				$session_id_field_name
253
-			);
254
-			if($session_id == 0) {
255
-				return new WSCMError(300, "Session not found");
256
-			} else {
257
-				return $session_id;
258
-			}
259
-		}
260
-	}
232
+    /**
233
+     * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
+     * in the system database
235
+     *
236
+     * @param string Session id field name
237
+     * @param string Session id value
238
+     * @return mixed System session id if the session was found, WSError otherwise
239
+     */
240
+    protected function getSessionId($session_id_field_name, $session_id_value)
241
+    {
242
+        if ($session_id_field_name == "chamilo_session_id") {
243
+            $session = SessionManager::fetch((int)$session_id_value);
244
+            if(!empty($session)) {
245
+                return intval($session_id_value);
246
+            } else {
247
+                return new WSCMError(300, "Session not found");
248
+            }
249
+        } else {
250
+            $session_id = SessionManager::getSessionIdFromOriginalId(
251
+                $session_id_value,
252
+                $session_id_field_name
253
+            );
254
+            if($session_id == 0) {
255
+                return new WSCMError(300, "Session not found");
256
+            } else {
257
+                return $session_id;
258
+            }
259
+        }
260
+    }
261 261
 
262
-	/**
263
-	 * Handles an error by calling the WSError error handler
264
-	 *
265
-	 * @param WSError Error
266
-	 */
267
-	protected function handleError($error) {
268
-		$handler = WSCMError::getErrorHandler();
269
-		$handler->handle($error);
270
-	}
262
+    /**
263
+     * Handles an error by calling the WSError error handler
264
+     *
265
+     * @param WSError Error
266
+     */
267
+    protected function handleError($error) {
268
+        $handler = WSCMError::getErrorHandler();
269
+        $handler->handle($error);
270
+    }
271 271
 
272
-	/**
273
-	 * Gets a successful result
274
-	 *
275
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
276
-	 */
277
-	protected function getSuccessfulResult() {
278
-		return array('code' => 0, 'message' => 'Operation was successful');
279
-	}
272
+    /**
273
+     * Gets a successful result
274
+     *
275
+     * @return array Array with a code of 0 and a message 'Operation was successful'
276
+     */
277
+    protected function getSuccessfulResult() {
278
+        return array('code' => 0, 'message' => 'Operation was successful');
279
+    }
280 280
 
281
-	/**
282
-	 * Test function. Returns the string success
283
-	 *
284
-	 * @return string Success
285
-	 */
286
-	public function test() {
287
-		return "success";
288
-	}
281
+    /**
282
+     * Test function. Returns the string success
283
+     *
284
+     * @return string Success
285
+     */
286
+    public function test() {
287
+        return "success";
288
+    }
289 289
 
290 290
         /**
291 291
          * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
Please login to merge, or discard this patch.
main/webservices/cm_webservice_inbox.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
             $table_message = Database::get_main_table(TABLE_MESSAGE);
38 38
 
39 39
             $sql_query = "SELECT id FROM $table_message " .
40
-                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
-                                     " ORDER BY send_date LIMIT $from,$number_of_items";
40
+                                        " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
+                                        " ORDER BY send_date LIMIT $from,$number_of_items";
42 42
 
43 43
             $sql_result = Database::query($sql_query);
44 44
             $message = "#";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $table_message = Database::get_main_table(TABLE_MESSAGE);
87 87
 
88 88
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
89
-                                     " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
89
+                                        " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
90 90
 
91 91
             $sql_result = Database::query($sql_query);
92 92
             $result = Database::fetch_row($sql_result);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
             $table_message = Database::get_main_table(TABLE_MESSAGE);
108 108
 
109 109
             $sql_query = "SELECT id FROM $table_message " .
110
-					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
-					 "ORDER BY send_date LIMIT $from,$number_of_items";
110
+                        "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
+                        "ORDER BY send_date LIMIT $from,$number_of_items";
112 112
 
113 113
             $sql_result = Database::query($sql_query);
114 114
             $message = "#";
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $table_message = Database::get_main_table(TABLE_MESSAGE);
158 158
 
159 159
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
160
-                                     " WHERE user_sender_id=".$user_id." AND id=".$id;
160
+                                        " WHERE user_sender_id=".$user_id." AND id=".$id;
161 161
 
162 162
             $sql_result = Database::query($sql_query);
163 163
             $result = Database::fetch_row($sql_result);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
             $table_message = Database::get_main_table(TABLE_MESSAGE);
189 189
 
190 190
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
191
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
191
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
192 192
             $result = Database::query($query);
193 193
 
194 194
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
195
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
195
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
196 196
             $result = Database::query($query);
197 197
 
198 198
             $inbox_last_id = Database::insert_id();
Please login to merge, or discard this patch.