@@ -9,255 +9,255 @@ discard block |
||
9 | 9 | $s = WSCMSoapServer::singleton(); |
10 | 10 | |
11 | 11 | $s->wsdl->addComplexType( |
12 | - 'course_id', |
|
13 | - 'complexType', |
|
14 | - 'struct', |
|
15 | - 'all', |
|
16 | - '', |
|
17 | - array( |
|
18 | - 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
19 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string') |
|
20 | - ) |
|
12 | + 'course_id', |
|
13 | + 'complexType', |
|
14 | + 'struct', |
|
15 | + 'all', |
|
16 | + '', |
|
17 | + array( |
|
18 | + 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
19 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string') |
|
20 | + ) |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | $s->wsdl->addComplexType( |
24 | - 'course_result', |
|
25 | - 'complexType', |
|
26 | - 'struct', |
|
27 | - 'all', |
|
28 | - '', |
|
29 | - array( |
|
30 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
31 | - 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
32 | - ) |
|
24 | + 'course_result', |
|
25 | + 'complexType', |
|
26 | + 'struct', |
|
27 | + 'all', |
|
28 | + '', |
|
29 | + array( |
|
30 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
31 | + 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
32 | + ) |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | $s->wsdl->addComplexType( |
36 | - 'course_result_array', |
|
37 | - 'complexType', |
|
38 | - 'array', |
|
39 | - '', |
|
40 | - 'SOAP-ENC:Array', |
|
41 | - array(), |
|
42 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')), |
|
43 | - 'tns:course_result' |
|
36 | + 'course_result_array', |
|
37 | + 'complexType', |
|
38 | + 'array', |
|
39 | + '', |
|
40 | + 'SOAP-ENC:Array', |
|
41 | + array(), |
|
42 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_result[]')), |
|
43 | + 'tns:course_result' |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | $s->register( |
47 | - 'WSCMCourse.DeleteCourse', |
|
48 | - array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string') |
|
47 | + 'WSCMCourse.DeleteCourse', |
|
48 | + array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string') |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | $s->register( |
52 | - 'WSCMCourse.DeleteCourses', |
|
53 | - array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'), |
|
54 | - array('return' => 'tns:course_result_array') |
|
52 | + 'WSCMCourse.DeleteCourses', |
|
53 | + array('secret_key' => 'xsd:string', 'courses' => 'tns:course_id[]'), |
|
54 | + array('return' => 'tns:course_result_array') |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | $s->register( |
58 | - 'WSCMCourse.CreateCourse', |
|
59 | - array( |
|
60 | - 'secret_key' => 'xsd:string', |
|
61 | - 'title' => 'xsd:string', |
|
62 | - 'category_code' => 'xsd:string', |
|
63 | - 'wanted_code' => 'xsd:string', |
|
64 | - 'tutor_name' => 'xsd:string', |
|
65 | - 'course_admin_user_id_field_name' => 'xsd:string', |
|
66 | - 'course_admin_user_id_value' => 'xsd:string', |
|
67 | - 'language' => 'xsd:string', |
|
68 | - 'course_id_field_name' => 'xsd:string', |
|
69 | - 'course_id_value' => 'xsd:string', |
|
70 | - 'extras' => 'tns:extra_field[]' |
|
71 | - ), |
|
72 | - array('return' => 'xsd:int') |
|
58 | + 'WSCMCourse.CreateCourse', |
|
59 | + array( |
|
60 | + 'secret_key' => 'xsd:string', |
|
61 | + 'title' => 'xsd:string', |
|
62 | + 'category_code' => 'xsd:string', |
|
63 | + 'wanted_code' => 'xsd:string', |
|
64 | + 'tutor_name' => 'xsd:string', |
|
65 | + 'course_admin_user_id_field_name' => 'xsd:string', |
|
66 | + 'course_admin_user_id_value' => 'xsd:string', |
|
67 | + 'language' => 'xsd:string', |
|
68 | + 'course_id_field_name' => 'xsd:string', |
|
69 | + 'course_id_value' => 'xsd:string', |
|
70 | + 'extras' => 'tns:extra_field[]' |
|
71 | + ), |
|
72 | + array('return' => 'xsd:int') |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | $s->wsdl->addComplexType( |
76 | - 'course_create', |
|
77 | - 'complexType', |
|
78 | - 'struct', |
|
79 | - 'all', |
|
80 | - '', |
|
81 | - array( |
|
82 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
83 | - 'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'), |
|
84 | - 'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'), |
|
85 | - 'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'), |
|
86 | - 'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'), |
|
87 | - 'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'), |
|
88 | - 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
89 | - 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
90 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
91 | - 'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]') |
|
92 | - ) |
|
76 | + 'course_create', |
|
77 | + 'complexType', |
|
78 | + 'struct', |
|
79 | + 'all', |
|
80 | + '', |
|
81 | + array( |
|
82 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
83 | + 'category_code' => array('name' => 'category_code', 'type' => 'xsd:string'), |
|
84 | + 'wanted_code' => array('name' => 'wanted_code', 'type' => 'xsd:int'), |
|
85 | + 'tutor_name' => array('name' => 'tutor_name', 'type' => 'xsd:string'), |
|
86 | + 'course_admin_user_id_field_name' => array('name' => 'course_admin_user_id_field_name', 'type' => 'xsd:string'), |
|
87 | + 'course_admin_user_id_value' => array('name' => 'course_admin_user_id_value', 'type' => 'xsd:string'), |
|
88 | + 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
89 | + 'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'), |
|
90 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
91 | + 'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]') |
|
92 | + ) |
|
93 | 93 | ); |
94 | 94 | |
95 | 95 | $s->wsdl->addComplexType( |
96 | - 'course_create_result', |
|
97 | - 'complexType', |
|
98 | - 'struct', |
|
99 | - 'all', |
|
100 | - '', |
|
101 | - array( |
|
102 | - 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
103 | - 'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'), |
|
104 | - 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
105 | - ) |
|
96 | + 'course_create_result', |
|
97 | + 'complexType', |
|
98 | + 'struct', |
|
99 | + 'all', |
|
100 | + '', |
|
101 | + array( |
|
102 | + 'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'), |
|
103 | + 'course_id_generated' => array('name' => 'course_id_generated', 'type' => 'xsd:int'), |
|
104 | + 'result' => array('name' => 'result', 'type' => 'tns:result') |
|
105 | + ) |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | $s->wsdl->addComplexType( |
109 | - 'course_create_result_array', |
|
110 | - 'complexType', |
|
111 | - 'array', |
|
112 | - '', |
|
113 | - 'SOAP-ENC:Array', |
|
114 | - array(), |
|
115 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')), |
|
116 | - 'tns:course_create_result' |
|
109 | + 'course_create_result_array', |
|
110 | + 'complexType', |
|
111 | + 'array', |
|
112 | + '', |
|
113 | + 'SOAP-ENC:Array', |
|
114 | + array(), |
|
115 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_create_result[]')), |
|
116 | + 'tns:course_create_result' |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | $s->register( |
120 | - 'WSCMCourse.CreateCourses', |
|
121 | - array( |
|
122 | - 'secret_key' => 'xsd:string', |
|
123 | - 'courses' => 'tns:course_create[]' |
|
124 | - ), |
|
125 | - array('return' => 'tns:course_create_result_array') |
|
120 | + 'WSCMCourse.CreateCourses', |
|
121 | + array( |
|
122 | + 'secret_key' => 'xsd:string', |
|
123 | + 'courses' => 'tns:course_create[]' |
|
124 | + ), |
|
125 | + array('return' => 'tns:course_create_result_array') |
|
126 | 126 | ); |
127 | 127 | |
128 | 128 | $s->register( |
129 | - 'WSCMCourse.EditCourse', |
|
130 | - array( |
|
131 | - 'secret_key' => 'xsd:string', |
|
132 | - 'course_id_field_name' => 'xsd:string', |
|
133 | - 'course_id_value' => 'xsd:string', |
|
134 | - 'title' => 'xsd:string', |
|
135 | - 'category_code' => 'xsd:string', |
|
136 | - 'department_name' => 'xsd:string', |
|
137 | - 'department_url' => 'xsd:string', |
|
138 | - 'language' => 'xsd:string', |
|
139 | - 'visibility' => 'xsd:int', |
|
140 | - 'subscribe' => 'xsd:int', |
|
141 | - 'unsubscribe' => 'xsd:int', |
|
142 | - 'visual_code' => 'xsd:string', |
|
143 | - 'extras' => 'tns:extra_field[]' |
|
144 | - ) |
|
129 | + 'WSCMCourse.EditCourse', |
|
130 | + array( |
|
131 | + 'secret_key' => 'xsd:string', |
|
132 | + 'course_id_field_name' => 'xsd:string', |
|
133 | + 'course_id_value' => 'xsd:string', |
|
134 | + 'title' => 'xsd:string', |
|
135 | + 'category_code' => 'xsd:string', |
|
136 | + 'department_name' => 'xsd:string', |
|
137 | + 'department_url' => 'xsd:string', |
|
138 | + 'language' => 'xsd:string', |
|
139 | + 'visibility' => 'xsd:int', |
|
140 | + 'subscribe' => 'xsd:int', |
|
141 | + 'unsubscribe' => 'xsd:int', |
|
142 | + 'visual_code' => 'xsd:string', |
|
143 | + 'extras' => 'tns:extra_field[]' |
|
144 | + ) |
|
145 | 145 | ); |
146 | 146 | |
147 | 147 | $s->wsdl->addComplexType( |
148 | - 'course', |
|
149 | - 'complexType', |
|
150 | - 'struct', |
|
151 | - 'all', |
|
152 | - '', |
|
153 | - array( |
|
154 | - 'id' => array('name' => 'id', 'type' => 'xsd:int'), |
|
155 | - 'code' => array('name' => 'code', 'type' => 'xsd:string'), |
|
156 | - 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
157 | - 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
158 | - 'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'), |
|
159 | - 'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), |
|
160 | - 'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'), |
|
161 | - 'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'), |
|
162 | - ) |
|
148 | + 'course', |
|
149 | + 'complexType', |
|
150 | + 'struct', |
|
151 | + 'all', |
|
152 | + '', |
|
153 | + array( |
|
154 | + 'id' => array('name' => 'id', 'type' => 'xsd:int'), |
|
155 | + 'code' => array('name' => 'code', 'type' => 'xsd:string'), |
|
156 | + 'title' => array('name' => 'title', 'type' => 'xsd:string'), |
|
157 | + 'language' => array('name' => 'language', 'type' => 'xsd:string'), |
|
158 | + 'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'), |
|
159 | + 'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), |
|
160 | + 'number_students' => array('name' => 'number_students', 'type' => 'xsd:int'), |
|
161 | + 'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'), |
|
162 | + ) |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | $s->wsdl->addComplexType( |
166 | - 'course_array', |
|
167 | - 'complexType', |
|
168 | - 'array', |
|
169 | - '', |
|
170 | - 'SOAP-ENC:Array', |
|
171 | - array(), |
|
172 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), |
|
173 | - 'tns:course' |
|
166 | + 'course_array', |
|
167 | + 'complexType', |
|
168 | + 'array', |
|
169 | + '', |
|
170 | + 'SOAP-ENC:Array', |
|
171 | + array(), |
|
172 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), |
|
173 | + 'tns:course' |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | $s->register( |
177 | - 'WSCMCourse.ListCourses', |
|
178 | - array( |
|
179 | - 'secret_key' => 'xsd:string', |
|
180 | - 'course_id_field_name' => 'xsd:string' |
|
181 | - ), |
|
182 | - array('return' => 'tns:course_array') |
|
177 | + 'WSCMCourse.ListCourses', |
|
178 | + array( |
|
179 | + 'secret_key' => 'xsd:string', |
|
180 | + 'course_id_field_name' => 'xsd:string' |
|
181 | + ), |
|
182 | + array('return' => 'tns:course_array') |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | $s->register( |
186 | - 'WSCMCourse.SubscribeUserToCourse', |
|
187 | - array( |
|
188 | - 'secret_key' => 'xsd:string', |
|
189 | - 'course_id_field_name' => 'xsd:string', |
|
190 | - 'course_id_value' => 'xsd:string', |
|
191 | - 'user_id_field_name' => 'xsd:string', |
|
192 | - 'user_id_value' => 'xsd:string', |
|
193 | - 'status' => 'xsd:int' |
|
194 | - ) |
|
186 | + 'WSCMCourse.SubscribeUserToCourse', |
|
187 | + array( |
|
188 | + 'secret_key' => 'xsd:string', |
|
189 | + 'course_id_field_name' => 'xsd:string', |
|
190 | + 'course_id_value' => 'xsd:string', |
|
191 | + 'user_id_field_name' => 'xsd:string', |
|
192 | + 'user_id_value' => 'xsd:string', |
|
193 | + 'status' => 'xsd:int' |
|
194 | + ) |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | $s->register( |
198 | - 'WSCMCourse.UnsubscribeUserFromCourse', |
|
199 | - array( |
|
200 | - 'secret_key' => 'xsd:string', |
|
201 | - 'course_id_field_name' => 'xsd:string', |
|
202 | - 'course_id_value' => 'xsd:string', |
|
203 | - 'user_id_field_name' => 'xsd:string', |
|
204 | - 'user_id_value' => 'xsd:string' |
|
205 | - ) |
|
198 | + 'WSCMCourse.UnsubscribeUserFromCourse', |
|
199 | + array( |
|
200 | + 'secret_key' => 'xsd:string', |
|
201 | + 'course_id_field_name' => 'xsd:string', |
|
202 | + 'course_id_value' => 'xsd:string', |
|
203 | + 'user_id_field_name' => 'xsd:string', |
|
204 | + 'user_id_value' => 'xsd:string' |
|
205 | + ) |
|
206 | 206 | ); |
207 | 207 | |
208 | 208 | $s->wsdl->addComplexType( |
209 | - 'course_description', |
|
210 | - 'complexType', |
|
211 | - 'struct', |
|
212 | - 'all', |
|
213 | - '', |
|
214 | - array( |
|
215 | - 'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'), |
|
216 | - 'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'), |
|
217 | - 'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string') |
|
218 | - ) |
|
209 | + 'course_description', |
|
210 | + 'complexType', |
|
211 | + 'struct', |
|
212 | + 'all', |
|
213 | + '', |
|
214 | + array( |
|
215 | + 'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:int'), |
|
216 | + 'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'), |
|
217 | + 'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string') |
|
218 | + ) |
|
219 | 219 | ); |
220 | 220 | |
221 | 221 | $s->wsdl->addComplexType( |
222 | - 'course_description_array', |
|
223 | - 'complexType', |
|
224 | - 'array', |
|
225 | - '', |
|
226 | - 'SOAP-ENC:Array', |
|
227 | - array(), |
|
228 | - array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')), |
|
229 | - 'tns:course_description' |
|
222 | + 'course_description_array', |
|
223 | + 'complexType', |
|
224 | + 'array', |
|
225 | + '', |
|
226 | + 'SOAP-ENC:Array', |
|
227 | + array(), |
|
228 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_description[]')), |
|
229 | + 'tns:course_description' |
|
230 | 230 | ); |
231 | 231 | |
232 | 232 | $s->register( |
233 | - 'WSCMCourse.GetCourseDescriptions', |
|
234 | - array( |
|
235 | - 'secret_key' => 'xsd:string', |
|
236 | - 'course_id_field_name' => 'xsd:string', |
|
237 | - 'course_id_value' => 'xsd:string' |
|
238 | - ), |
|
239 | - array('return' => 'tns:course_description_array') |
|
233 | + 'WSCMCourse.GetCourseDescriptions', |
|
234 | + array( |
|
235 | + 'secret_key' => 'xsd:string', |
|
236 | + 'course_id_field_name' => 'xsd:string', |
|
237 | + 'course_id_value' => 'xsd:string' |
|
238 | + ), |
|
239 | + array('return' => 'tns:course_description_array') |
|
240 | 240 | ); |
241 | 241 | |
242 | 242 | $s->register( |
243 | - 'WSCMCourse.EditCourseDescription', |
|
244 | - array( |
|
245 | - 'secret_key' => 'xsd:string', |
|
246 | - 'course_id_field_name' => 'xsd:string', |
|
247 | - 'course_id_value' => 'xsd:string', |
|
248 | - 'course_desc_id' => 'xsd:int', |
|
249 | - 'course_desc_title' => 'xsd:string', |
|
250 | - 'course_desc_content' => 'xsd:string' |
|
251 | - ) |
|
243 | + 'WSCMCourse.EditCourseDescription', |
|
244 | + array( |
|
245 | + 'secret_key' => 'xsd:string', |
|
246 | + 'course_id_field_name' => 'xsd:string', |
|
247 | + 'course_id_value' => 'xsd:string', |
|
248 | + 'course_desc_id' => 'xsd:int', |
|
249 | + 'course_desc_title' => 'xsd:string', |
|
250 | + 'course_desc_content' => 'xsd:string' |
|
251 | + ) |
|
252 | 252 | ); |
253 | 253 | |
254 | 254 | $s->register( |
255 | - 'WSCMCourse.unreadMessage', |
|
256 | - array( |
|
257 | - 'username' => 'xsd:string', |
|
258 | - 'password' => 'xsd:string', |
|
259 | - ), |
|
260 | - array('return' => 'xsd:string'), |
|
255 | + 'WSCMCourse.unreadMessage', |
|
256 | + array( |
|
257 | + 'username' => 'xsd:string', |
|
258 | + 'password' => 'xsd:string', |
|
259 | + ), |
|
260 | + array('return' => 'xsd:string'), |
|
261 | 261 | 'urn:WSCMService', |
262 | 262 | '', |
263 | 263 | '', |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | |
269 | 269 | |
270 | 270 | $s->register( |
271 | - 'WSCMCourse.getIdMessage', |
|
272 | - array( |
|
273 | - 'username' => 'xsd:string', |
|
274 | - 'password' => 'xsd:string', |
|
275 | - ), |
|
276 | - array('return' => 'xsd:string'), |
|
271 | + 'WSCMCourse.getIdMessage', |
|
272 | + array( |
|
273 | + 'username' => 'xsd:string', |
|
274 | + 'password' => 'xsd:string', |
|
275 | + ), |
|
276 | + array('return' => 'xsd:string'), |
|
277 | 277 | 'urn:WSCMService', |
278 | 278 | '', |
279 | 279 | '', |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | return $foruns_id; |
35 | - } else |
|
36 | - return get_lang('InvalidId'); |
|
35 | + } else { |
|
36 | + return get_lang('InvalidId'); |
|
37 | + } |
|
37 | 38 | } |
38 | 39 | |
39 | 40 | public function get_forum_title($username, $password, $course_code, $forum_id) |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | |
55 | 56 | $forum_title = utf8_decode($forum_info['forum_title']); |
56 | 57 | return $forum_title; |
57 | - } else |
|
58 | - return get_lang('InvalidId'); |
|
58 | + } else { |
|
59 | + return get_lang('InvalidId'); |
|
60 | + } |
|
59 | 61 | } |
60 | 62 | |
61 | 63 | public function get_forum_threads_id($username, $password, $course_code, $forum_id) |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | |
74 | 76 | return $threads_id; |
75 | 77 | |
76 | - } else |
|
77 | - return get_lang('InvalidId'); |
|
78 | + } else { |
|
79 | + return get_lang('InvalidId'); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | public function get_forum_thread_data($username, $password, $course_code, $thread_id, $field) |
@@ -115,8 +118,9 @@ discard block |
||
115 | 118 | |
116 | 119 | return $thread_info[$field_table]; |
117 | 120 | |
118 | - } else |
|
119 | - return get_lang('InvalidId'); |
|
121 | + } else { |
|
122 | + return get_lang('InvalidId'); |
|
123 | + } |
|
120 | 124 | } |
121 | 125 | |
122 | 126 | public function get_forum_thread_title($username, $password, $course_code, $thread_id) |
@@ -139,8 +143,9 @@ discard block |
||
139 | 143 | |
140 | 144 | return $thread_info[$field_table]; |
141 | 145 | |
142 | - } else |
|
143 | - return get_lang('InvalidId'); |
|
146 | + } else { |
|
147 | + return get_lang('InvalidId'); |
|
148 | + } |
|
144 | 149 | } |
145 | 150 | |
146 | 151 | |
@@ -184,8 +189,9 @@ discard block |
||
184 | 189 | } |
185 | 190 | } |
186 | 191 | return $posts_id; |
187 | - } else |
|
188 | - return get_lang('InvalidId'); |
|
192 | + } else { |
|
193 | + return get_lang('InvalidId'); |
|
194 | + } |
|
189 | 195 | } |
190 | 196 | |
191 | 197 | public function get_post_data($username, $password, $course_code, $post_id, $field) |
@@ -226,8 +232,9 @@ discard block |
||
226 | 232 | $field_table = "title"; |
227 | 233 | } |
228 | 234 | return (htmlcode) ? html_entity_decode($post_info[$field_table]) : $post_info[$field_table]; |
229 | - } else |
|
230 | - return get_lang('InvalidId'); |
|
235 | + } else { |
|
236 | + return get_lang('InvalidId'); |
|
237 | + } |
|
231 | 238 | } |
232 | 239 | |
233 | 240 | public function send_post($username, $password, $course_code, $forum_id, $thread_id, $title, $content) |
@@ -269,8 +276,9 @@ discard block |
||
269 | 276 | |
270 | 277 | //send_notification_mails($thread_id, $values); |
271 | 278 | |
272 | - } else |
|
273 | - return get_lang('InvalidId'); |
|
279 | + } else { |
|
280 | + return get_lang('InvalidId'); |
|
281 | + } |
|
274 | 282 | |
275 | 283 | } |
276 | 284 |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | public function get_foruns_id($username, $password, $course_code) |
21 | 21 | { |
22 | - if($this->verifyUserPass($username, $password) == "valid") |
|
22 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
23 | 23 | { |
24 | 24 | $course_db = CourseManager::get_course_information($course_code); |
25 | - $foruns_info = get_forums($id='', $course_db['code']); |
|
25 | + $foruns_info = get_forums($id = '', $course_db['code']); |
|
26 | 26 | $foruns_id = '#'; |
27 | 27 | foreach ($foruns_info as $forum) |
28 | 28 | { |
29 | - if( isset($forum['forum_id'])) |
|
29 | + if (isset($forum['forum_id'])) |
|
30 | 30 | { |
31 | 31 | $foruns_id .= $forum['forum_id']."#"; |
32 | 32 | } |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | |
39 | 39 | public function get_forum_title($username, $password, $course_code, $forum_id) |
40 | 40 | { |
41 | - if($this->verifyUserPass($username, $password) == "valid") |
|
41 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
42 | 42 | { |
43 | 43 | $course_db = CourseManager::get_course_information($course_code); |
44 | 44 | $table_forums = Database :: get_course_table(TABLE_FORUM, $course_db['db_name']); |
45 | 45 | $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']); |
46 | 46 | |
47 | - $sql="SELECT * FROM ".$table_forums." forums, ".$table_item_property." item_properties |
|
47 | + $sql = "SELECT * FROM ".$table_forums." forums, ".$table_item_property." item_properties |
|
48 | 48 | WHERE item_properties.tool='".TOOL_FORUM."' |
49 | 49 | AND item_properties.ref='".Database::escape_string($forum_id)."' |
50 | 50 | AND forums.forum_id='".Database::escape_string($forum_id)."'"; |
51 | - $result=Database::query($sql); |
|
52 | - $forum_info=Database::fetch_array($result); |
|
51 | + $result = Database::query($sql); |
|
52 | + $forum_info = Database::fetch_array($result); |
|
53 | 53 | $forum_info['approval_direct_post'] = 0; // we can't anymore change this option, so it should always be activated |
54 | 54 | |
55 | 55 | $forum_title = utf8_decode($forum_info['forum_title']); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | |
61 | 61 | public function get_forum_threads_id($username, $password, $course_code, $forum_id) |
62 | 62 | { |
63 | - if($this->verifyUserPass($username, $password) == "valid") { |
|
63 | + if ($this->verifyUserPass($username, $password) == "valid") { |
|
64 | 64 | $threads_info = get_threads($forum_id, $course_code); |
65 | 65 | $threads_id = '#'; |
66 | 66 | foreach ($threads_info as $thread) |
67 | 67 | { |
68 | - if( isset($thread['thread_id'])) |
|
68 | + if (isset($thread['thread_id'])) |
|
69 | 69 | { |
70 | 70 | $threads_id .= $thread['thread_id']."#"; |
71 | 71 | } |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | |
80 | 80 | public function get_forum_thread_data($username, $password, $course_code, $thread_id, $field) |
81 | 81 | { |
82 | - if($this->verifyUserPass($username, $password) == "valid") |
|
82 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
83 | 83 | { |
84 | 84 | $course_db = CourseManager::get_course_information($course_code); |
85 | 85 | $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']); |
86 | 86 | $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']); |
87 | 87 | |
88 | - $sql="SELECT * FROM ".$table_threads." threads, ".$table_item_property." item_properties |
|
88 | + $sql = "SELECT * FROM ".$table_threads." threads, ".$table_item_property." item_properties |
|
89 | 89 | WHERE item_properties.tool='".TOOL_FORUM_THREAD."' |
90 | 90 | AND item_properties.ref='".Database::escape_string($thread_id)."' |
91 | 91 | AND threads.thread_id='".Database::escape_string($thread_id)."'"; |
92 | - $result=Database::query($sql); |
|
93 | - $thread_info=Database::fetch_array($result); |
|
92 | + $result = Database::query($sql); |
|
93 | + $thread_info = Database::fetch_array($result); |
|
94 | 94 | |
95 | 95 | switch ($field) |
96 | 96 | { |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | |
122 | 122 | public function get_forum_thread_title($username, $password, $course_code, $thread_id) |
123 | 123 | { |
124 | - if($this->verifyUserPass($username, $password) == "valid") |
|
124 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
125 | 125 | { |
126 | 126 | $course_db = CourseManager::get_course_information($course_code); |
127 | 127 | $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']); |
128 | 128 | $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']); |
129 | 129 | |
130 | - $sql="SELECT * FROM ".$table_threads." threads, ".$table_item_property." item_properties |
|
130 | + $sql = "SELECT * FROM ".$table_threads." threads, ".$table_item_property." item_properties |
|
131 | 131 | WHERE item_properties.tool='".TOOL_FORUM_THREAD."' |
132 | 132 | AND item_properties.ref='".Database::escape_string($thread_id)."' |
133 | 133 | AND threads.thread_id='".Database::escape_string($thread_id)."'"; |
134 | - $result=Database::query($sql); |
|
135 | - $thread_info=Database::fetch_array($result); |
|
134 | + $result = Database::query($sql); |
|
135 | + $thread_info = Database::fetch_array($result); |
|
136 | 136 | |
137 | 137 | $htmlcode = true; |
138 | 138 | $field_table = "thread_title"; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | public function get_posts_id($username, $password, $course_code, $thread_id) |
148 | 148 | { |
149 | - if($this->verifyUserPass($username, $password) == "valid") |
|
149 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
150 | 150 | { |
151 | 151 | $course_db = CourseManager::get_course_information($course_code); |
152 | 152 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $table_posts = Database :: get_course_table(TABLE_FORUM_POST, $course_db['db_name']); |
155 | 155 | |
156 | 156 | // note: change these SQL so that only the relevant fields of the user table are used |
157 | - if (api_is_allowed_to_edit(null,true)) { |
|
157 | + if (api_is_allowed_to_edit(null, true)) { |
|
158 | 158 | $sql = "SELECT * FROM $table_posts posts |
159 | 159 | LEFT JOIN $table_users users |
160 | 160 | ON posts.poster_id=users.user_id |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | AND posts.visible='1' |
170 | 170 | ORDER BY posts.post_id ASC"; |
171 | 171 | } |
172 | - $result=Database::query($sql); |
|
173 | - while ($row=Database::fetch_array($result)) { |
|
174 | - $posts_info[]=$row; |
|
172 | + $result = Database::query($sql); |
|
173 | + while ($row = Database::fetch_array($result)) { |
|
174 | + $posts_info[] = $row; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | $posts_id = '#'; |
178 | 178 | |
179 | 179 | foreach ($posts_info as $post) |
180 | 180 | { |
181 | - if( isset($post['post_id'])) |
|
181 | + if (isset($post['post_id'])) |
|
182 | 182 | { |
183 | 183 | $posts_id .= $post['post_id']."#"; |
184 | 184 | } |
@@ -190,16 +190,16 @@ discard block |
||
190 | 190 | |
191 | 191 | public function get_post_data($username, $password, $course_code, $post_id, $field) |
192 | 192 | { |
193 | - if($this->verifyUserPass($username, $password) == "valid") |
|
193 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
194 | 194 | { |
195 | 195 | $course_db = CourseManager::get_course_information($course_code); |
196 | 196 | |
197 | 197 | $table_posts = Database :: get_course_table(TABLE_FORUM_POST, $course_db['db_name']); |
198 | 198 | $table_users = Database :: get_main_table(TABLE_MAIN_USER); |
199 | 199 | |
200 | - $sql="SELECT * FROM ".$table_posts."posts, ".$table_users." users WHERE posts.poster_id=users.user_id AND posts.post_id='".Database::escape_string($post_id)."'"; |
|
201 | - $result=Database::query($sql); |
|
202 | - $post_info =Database::fetch_array($result); |
|
200 | + $sql = "SELECT * FROM ".$table_posts."posts, ".$table_users." users WHERE posts.poster_id=users.user_id AND posts.post_id='".Database::escape_string($post_id)."'"; |
|
201 | + $result = Database::query($sql); |
|
202 | + $post_info = Database::fetch_array($result); |
|
203 | 203 | |
204 | 204 | $htmlcode = false; |
205 | 205 | switch ($field) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | public function send_post($username, $password, $course_code, $forum_id, $thread_id, $title, $content) |
234 | 234 | { |
235 | - if($this->verifyUserPass($username, $password) == "valid") |
|
235 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
236 | 236 | { |
237 | 237 | $em = Database::getManager(); |
238 | 238 | $course_db = CourseManager::get_course_information($course_code); |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']); |
242 | 242 | $forum_table_attachment = Database :: get_course_table(TABLE_FORUM_ATTACHMENT, $course_db['db_name']); |
243 | 243 | $table_posts = Database :: get_course_table(TABLE_FORUM_POST, $course_db['db_name']); |
244 | - $post_date=date('Y-m-d H:i:s'); |
|
245 | - $visible=1; |
|
246 | - $has_attachment=false; |
|
244 | + $post_date = date('Y-m-d H:i:s'); |
|
245 | + $visible = 1; |
|
246 | + $has_attachment = false; |
|
247 | 247 | $my_post = ''; |
248 | 248 | $post_notification = ''; |
249 | 249 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 'all', |
27 | 27 | '', |
28 | 28 | array( |
29 | - 'name'=>'code' , 'type'=>'xsd:string', |
|
30 | - 'name'=>'title' , 'type'=>'xsd:string', |
|
31 | - 'name'=>'url' , 'type'=>'xsd:string', |
|
32 | - 'name'=>'teacher', 'type'=>'xsd:string', |
|
33 | - 'name'=>'language','type'=>'xsd:string', |
|
29 | + 'name'=>'code' , 'type'=>'xsd:string', |
|
30 | + 'name'=>'title' , 'type'=>'xsd:string', |
|
31 | + 'name'=>'url' , 'type'=>'xsd:string', |
|
32 | + 'name'=>'teacher', 'type'=>'xsd:string', |
|
33 | + 'name'=>'language','type'=>'xsd:string', |
|
34 | 34 | ) |
35 | 35 | ); |
36 | 36 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | // Register the method to expose |
52 | 52 | $server->register('WSCourseListOfUser', // method name |
53 | 53 | array('username' => 'xsd:string', |
54 | - 'signature' => 'xsd:string'), // input parameters |
|
54 | + 'signature' => 'xsd:string'), // input parameters |
|
55 | 55 | array('return' => 'xsd:Array'), // output parameters |
56 | 56 | 'urn:WSUserInfo', // namespace |
57 | 57 | 'urn:WSUserInfo#WSUserInfo', // soapaction |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $list = UserManager::get_api_keys($user_id, 'dokeos'); |
78 | 78 | $key = ''; |
79 | 79 | foreach ($list as $key) { |
80 | - break; |
|
80 | + break; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $local_key = $username.$key; |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | // Register the method to expose |
130 | 130 | $server->register('WSEventsList', // method name |
131 | 131 | array('username' => 'xsd:string', |
132 | - 'signature' => 'xsd:string', |
|
133 | - 'datestart' => 'xsd:int', |
|
134 | - 'dateend' => 'xsd:int'), // input parameters |
|
132 | + 'signature' => 'xsd:string', |
|
133 | + 'datestart' => 'xsd:int', |
|
134 | + 'dateend' => 'xsd:int'), // input parameters |
|
135 | 135 | array('return' => 'xsd:Array'), // output parameters |
136 | 136 | 'urn:WSUserInfo', // namespace |
137 | 137 | 'urn:WSUserInfo#WSEventsList', // soapaction |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $list = UserManager::get_api_keys($user_id, 'dokeos'); |
160 | 160 | $key = ''; |
161 | 161 | foreach ($list as $key) { |
162 | - break; |
|
162 | + break; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $local_key = $username.$key; |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | 'all', |
27 | 27 | '', |
28 | 28 | array( |
29 | - 'name'=>'code' , 'type'=>'xsd:string', |
|
30 | - 'name'=>'title' , 'type'=>'xsd:string', |
|
31 | - 'name'=>'url' , 'type'=>'xsd:string', |
|
29 | + 'name'=>'code', 'type'=>'xsd:string', |
|
30 | + 'name'=>'title', 'type'=>'xsd:string', |
|
31 | + 'name'=>'url', 'type'=>'xsd:string', |
|
32 | 32 | 'name'=>'teacher', 'type'=>'xsd:string', |
33 | - 'name'=>'language','type'=>'xsd:string', |
|
33 | + 'name'=>'language', 'type'=>'xsd:string', |
|
34 | 34 | ) |
35 | 35 | ); |
36 | 36 | |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | ); |
50 | 50 | |
51 | 51 | // Register the method to expose |
52 | -$server->register('WSCourseListOfUser', // method name |
|
52 | +$server->register('WSCourseListOfUser', // method name |
|
53 | 53 | array('username' => 'xsd:string', |
54 | - 'signature' => 'xsd:string'), // input parameters |
|
55 | - array('return' => 'xsd:Array'), // output parameters |
|
56 | - 'urn:WSUserInfo', // namespace |
|
57 | - 'urn:WSUserInfo#WSUserInfo', // soapaction |
|
58 | - 'rpc', // style |
|
59 | - 'encoded', // use |
|
54 | + 'signature' => 'xsd:string'), // input parameters |
|
55 | + array('return' => 'xsd:Array'), // output parameters |
|
56 | + 'urn:WSUserInfo', // namespace |
|
57 | + 'urn:WSUserInfo#WSUserInfo', // soapaction |
|
58 | + 'rpc', // style |
|
59 | + 'encoded', // use |
|
60 | 60 | 'This service returns a list of courses' // documentation |
61 | 61 | ); |
62 | 62 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | 'all', |
105 | 105 | '', |
106 | 106 | array( |
107 | - 'name'=>'datestart','type'=>'xsd:string', |
|
108 | - 'name'=>'dateend','type'=>'xsd:string', |
|
109 | - 'name'=>'title','type'=>'xsd:string', |
|
110 | - 'name'=>'link','type'=>'xsd:string', |
|
111 | - 'name'=>'coursetitle','type'=>'xsd:string', |
|
107 | + 'name'=>'datestart', 'type'=>'xsd:string', |
|
108 | + 'name'=>'dateend', 'type'=>'xsd:string', |
|
109 | + 'name'=>'title', 'type'=>'xsd:string', |
|
110 | + 'name'=>'link', 'type'=>'xsd:string', |
|
111 | + 'name'=>'coursetitle', 'type'=>'xsd:string', |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | ); |
128 | 128 | |
129 | 129 | // Register the method to expose |
130 | -$server->register('WSEventsList', // method name |
|
130 | +$server->register('WSEventsList', // method name |
|
131 | 131 | array('username' => 'xsd:string', |
132 | 132 | 'signature' => 'xsd:string', |
133 | 133 | 'datestart' => 'xsd:int', |
134 | - 'dateend' => 'xsd:int'), // input parameters |
|
135 | - array('return' => 'xsd:Array'), // output parameters |
|
136 | - 'urn:WSUserInfo', // namespace |
|
137 | - 'urn:WSUserInfo#WSEventsList', // soapaction |
|
138 | - 'rpc', // style |
|
139 | - 'encoded', // use |
|
134 | + 'dateend' => 'xsd:int'), // input parameters |
|
135 | + array('return' => 'xsd:Array'), // output parameters |
|
136 | + 'urn:WSUserInfo', // namespace |
|
137 | + 'urn:WSUserInfo#WSEventsList', // soapaction |
|
138 | + 'rpc', // style |
|
139 | + 'encoded', // use |
|
140 | 140 | 'This service returns a list of events of the courses the given user is subscribed to' // documentation |
141 | 141 | ); |
142 | 142 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | |
172 | 172 | $user_id = UserManager::get_user_id_from_username($username); |
173 | 173 | if ($user_id === false) { return $events_list; } // Error in user id recovery. |
174 | - $ds = substr($datestart,0,4).'-'.substr($datestart,4,2).'-'.substr($datestart,6,2).' 00:00:00'; |
|
175 | - $de = substr($dateend,0,4).'-'.substr($dateend,4,2).'-'.substr($dateend,6,2).' 00:00:00'; |
|
174 | + $ds = substr($datestart, 0, 4).'-'.substr($datestart, 4, 2).'-'.substr($datestart, 6, 2).' 00:00:00'; |
|
175 | + $de = substr($dateend, 0, 4).'-'.substr($dateend, 4, 2).'-'.substr($dateend, 6, 2).' 00:00:00'; |
|
176 | 176 | $events_list = Agenda::get_personal_agenda_items_between_dates($user_id, $ds, $de); |
177 | 177 | return $events_list; |
178 | 178 | } |
@@ -11,84 +11,84 @@ discard block |
||
11 | 11 | * SOAP error handler. Handles an error sending a SOAP fault |
12 | 12 | */ |
13 | 13 | class WSSoapErrorHandler implements WSErrorHandler { |
14 | - /** |
|
15 | - * Handles the error by sending a SOAP fault through the server |
|
16 | - * |
|
17 | - * @param WSError Error to handle |
|
18 | - */ |
|
19 | - public function handle($error) { |
|
20 | - $server = WSSoapServer::singleton(); |
|
21 | - $server->fault(strval($error->code), $error->message); |
|
22 | - } |
|
14 | + /** |
|
15 | + * Handles the error by sending a SOAP fault through the server |
|
16 | + * |
|
17 | + * @param WSError Error to handle |
|
18 | + */ |
|
19 | + public function handle($error) { |
|
20 | + $server = WSSoapServer::singleton(); |
|
21 | + $server->fault(strval($error->code), $error->message); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * SOAP server wrapper implementing a Singleton |
27 | 27 | */ |
28 | 28 | class WSSoapServer { |
29 | - /** |
|
30 | - * SOAP server instance |
|
31 | - * |
|
32 | - * @var soap_server |
|
33 | - */ |
|
34 | - private static $_instance; |
|
29 | + /** |
|
30 | + * SOAP server instance |
|
31 | + * |
|
32 | + * @var soap_server |
|
33 | + */ |
|
34 | + private static $_instance; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Private constructor |
|
38 | - */ |
|
39 | - private function __construct() { |
|
40 | - } |
|
36 | + /** |
|
37 | + * Private constructor |
|
38 | + */ |
|
39 | + private function __construct() { |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Singleton method |
|
44 | - */ |
|
45 | - public static function singleton() { |
|
46 | - if(!isset(self::$_instance)) { |
|
47 | - self::$_instance = new soap_server(); |
|
48 | - // Set the error handler |
|
49 | - WSError::setErrorHandler(new WSSoapErrorHandler()); |
|
50 | - // Configure the service |
|
51 | - self::$_instance->configureWSDL('WSService', 'urn:WSService'); |
|
52 | - } |
|
42 | + /** |
|
43 | + * Singleton method |
|
44 | + */ |
|
45 | + public static function singleton() { |
|
46 | + if(!isset(self::$_instance)) { |
|
47 | + self::$_instance = new soap_server(); |
|
48 | + // Set the error handler |
|
49 | + WSError::setErrorHandler(new WSSoapErrorHandler()); |
|
50 | + // Configure the service |
|
51 | + self::$_instance->configureWSDL('WSService', 'urn:WSService'); |
|
52 | + } |
|
53 | 53 | |
54 | - return self::$_instance; |
|
55 | - } |
|
54 | + return self::$_instance; |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $s = WSSoapServer::singleton(); |
59 | 59 | |
60 | 60 | $s->wsdl->addComplexType( |
61 | - 'result', |
|
62 | - 'complexType', |
|
63 | - 'struct', |
|
64 | - 'all', |
|
65 | - '', |
|
66 | - array( |
|
67 | - 'code' => array('name' => 'code', 'type' => 'xsd:int'), |
|
68 | - 'message' => array('name' => 'message', 'type' => 'xsd:string') |
|
69 | - ) |
|
61 | + 'result', |
|
62 | + 'complexType', |
|
63 | + 'struct', |
|
64 | + 'all', |
|
65 | + '', |
|
66 | + array( |
|
67 | + 'code' => array('name' => 'code', 'type' => 'xsd:int'), |
|
68 | + 'message' => array('name' => 'message', 'type' => 'xsd:string') |
|
69 | + ) |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $s->wsdl->addComplexType( |
73 | - 'extras', |
|
74 | - 'complexType', |
|
75 | - 'struct', |
|
76 | - 'all', |
|
77 | - '', |
|
78 | - array( |
|
79 | - 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), |
|
80 | - 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') |
|
81 | - ) |
|
73 | + 'extras', |
|
74 | + 'complexType', |
|
75 | + 'struct', |
|
76 | + 'all', |
|
77 | + '', |
|
78 | + array( |
|
79 | + 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), |
|
80 | + 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') |
|
81 | + ) |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | $s->wsdl->addComplexType( |
85 | - 'extra_field', |
|
86 | - 'complexType', |
|
87 | - 'array', |
|
88 | - '', |
|
89 | - 'SOAP-ENC:Array', |
|
90 | - array(), |
|
91 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras' |
|
85 | + 'extra_field', |
|
86 | + 'complexType', |
|
87 | + 'array', |
|
88 | + '', |
|
89 | + 'SOAP-ENC:Array', |
|
90 | + array(), |
|
91 | + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras' |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | /* |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | |
108 | 108 | $s->register( |
109 | - 'WS.test', |
|
110 | - array(), |
|
111 | - array('return' => 'xsd:string') |
|
109 | + 'WS.test', |
|
110 | + array(), |
|
111 | + array('return' => 'xsd:string') |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | require_once(dirname(__FILE__).'/soap_user.php'); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * Singleton method |
44 | 44 | */ |
45 | 45 | public static function singleton() { |
46 | - if(!isset(self::$_instance)) { |
|
46 | + if (!isset(self::$_instance)) { |
|
47 | 47 | self::$_instance = new soap_server(); |
48 | 48 | // Set the error handler |
49 | 49 | WSError::setErrorHandler(new WSSoapErrorHandler()); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | '', |
89 | 89 | 'SOAP-ENC:Array', |
90 | 90 | array(), |
91 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras' |
|
91 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')), 'tns:extras' |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | /* |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | |
13 | 13 | $s->register( |
14 | 14 | 'WSCMForum.get_foruns_id', |
15 | - array( |
|
16 | - 'username' => 'xsd:string', |
|
17 | - 'password' => 'xsd:string', |
|
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 | '', |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | ); |
27 | 27 | |
28 | 28 | $s->register( |
29 | - 'WSCMForum.get_forum_title', |
|
30 | - array( |
|
31 | - 'username' => 'xsd:string', |
|
32 | - 'password' => 'xsd:string', |
|
29 | + 'WSCMForum.get_forum_title', |
|
30 | + array( |
|
31 | + 'username' => 'xsd:string', |
|
32 | + 'password' => 'xsd:string', |
|
33 | 33 | 'course_code' => 'xsd:string', |
34 | 34 | 'forum_id' => 'xsd:string' |
35 | - ), |
|
36 | - array('return' => 'xsd:string'), |
|
35 | + ), |
|
36 | + array('return' => 'xsd:string'), |
|
37 | 37 | 'urn:WSCMService', |
38 | 38 | '', |
39 | 39 | '', |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | ); |
43 | 43 | |
44 | 44 | $s->register( |
45 | - 'WSCMForum.get_forum_threads_id', |
|
46 | - array( |
|
47 | - 'username' => 'xsd:string', |
|
48 | - 'password' => 'xsd:string', |
|
45 | + 'WSCMForum.get_forum_threads_id', |
|
46 | + array( |
|
47 | + 'username' => 'xsd:string', |
|
48 | + 'password' => 'xsd:string', |
|
49 | 49 | 'course_code' => 'xsd:string', |
50 | 50 | 'forum_id' => 'xsd:string' |
51 | - ), |
|
52 | - array('return' => 'xsd:string'), |
|
51 | + ), |
|
52 | + array('return' => 'xsd:string'), |
|
53 | 53 | 'urn:WSCMService', |
54 | 54 | '', |
55 | 55 | '', |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | $s->register( |
61 | - 'WSCMForum.get_forum_thread_data', |
|
62 | - array( |
|
63 | - 'username' => 'xsd:string', |
|
64 | - 'password' => 'xsd:string', |
|
61 | + 'WSCMForum.get_forum_thread_data', |
|
62 | + array( |
|
63 | + 'username' => 'xsd:string', |
|
64 | + 'password' => 'xsd:string', |
|
65 | 65 | 'course_code' => 'xsd:string', |
66 | 66 | 'thread_id' => 'xsd:string', |
67 | 67 | 'field' => 'xsd:string' |
68 | - ), |
|
69 | - array('return' => 'xsd:string'), |
|
68 | + ), |
|
69 | + array('return' => 'xsd:string'), |
|
70 | 70 | 'urn:WSCMService', |
71 | 71 | '', |
72 | 72 | '', |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | $s->register( |
78 | - 'WSCMForum.get_forum_thread_title', |
|
79 | - array( |
|
80 | - 'username' => 'xsd:string', |
|
81 | - 'password' => 'xsd:string', |
|
78 | + 'WSCMForum.get_forum_thread_title', |
|
79 | + array( |
|
80 | + 'username' => 'xsd:string', |
|
81 | + 'password' => 'xsd:string', |
|
82 | 82 | 'course_code' => 'xsd:string', |
83 | 83 | 'thread_id' => 'xsd:string' |
84 | - ), |
|
85 | - array('return' => 'xsd:string'), |
|
84 | + ), |
|
85 | + array('return' => 'xsd:string'), |
|
86 | 86 | 'urn:WSCMService', |
87 | 87 | '', |
88 | 88 | '', |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | $s->register( |
95 | - 'WSCMForum.get_posts_id', |
|
96 | - array( |
|
97 | - 'username' => 'xsd:string', |
|
98 | - 'password' => 'xsd:string', |
|
95 | + 'WSCMForum.get_posts_id', |
|
96 | + array( |
|
97 | + 'username' => 'xsd:string', |
|
98 | + 'password' => 'xsd:string', |
|
99 | 99 | 'course_code' => 'xsd:string', |
100 | 100 | 'thread_id' => 'xsd:string' |
101 | - ), |
|
102 | - array('return' => 'xsd:string'), |
|
101 | + ), |
|
102 | + array('return' => 'xsd:string'), |
|
103 | 103 | 'urn:WSCMService', |
104 | 104 | '', |
105 | 105 | '', |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | $s->register( |
111 | - 'WSCMForum.get_post_data', |
|
112 | - array( |
|
113 | - 'username' => 'xsd:string', |
|
114 | - 'password' => 'xsd:string', |
|
111 | + 'WSCMForum.get_post_data', |
|
112 | + array( |
|
113 | + 'username' => 'xsd:string', |
|
114 | + 'password' => 'xsd:string', |
|
115 | 115 | 'course_code' => 'xsd:string', |
116 | 116 | 'post_id' => 'xsd:string', |
117 | 117 | 'field' => 'xsd:string' |
118 | - ), |
|
119 | - array('return' => 'xsd:string'), |
|
118 | + ), |
|
119 | + array('return' => 'xsd:string'), |
|
120 | 120 | 'urn:WSCMService', |
121 | 121 | '', |
122 | 122 | '', |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | $s->register( |
129 | - 'WSCMForum.send_post', |
|
130 | - array( |
|
131 | - 'username' => 'xsd:string', |
|
132 | - 'password' => 'xsd:string', |
|
129 | + 'WSCMForum.send_post', |
|
130 | + array( |
|
131 | + 'username' => 'xsd:string', |
|
132 | + 'password' => 'xsd:string', |
|
133 | 133 | 'course_code' => 'xsd:string', |
134 | 134 | 'forum_id' => 'xsd:string', |
135 | 135 | 'thread_id' => 'xsd:string', |
136 | 136 | 'title' => 'xsd:string', |
137 | 137 | 'content' => 'xsd:string' |
138 | - ), |
|
139 | - array('return' => 'xsd:string'), |
|
138 | + ), |
|
139 | + array('return' => 'xsd:string'), |
|
140 | 140 | 'urn:WSCMService', |
141 | 141 | '', |
142 | 142 | '', |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | $script = isset($_POST['script']) ? $_POST['script'] : false; |
16 | 16 | $function = isset($_POST['function']) ? $_POST['function'] : false; |
17 | 17 | |
18 | -$contact= $server.$script.'?wsdl'; |
|
18 | +$contact = $server.$script.'?wsdl'; |
|
19 | 19 | |
20 | 20 | $client = new nusoap_client($contact); |
21 | 21 | $err = $client->getError(); |
22 | 22 | if ($err) { |
23 | 23 | // Display the error |
24 | - echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; |
|
24 | + echo '<h2>Constructor error</h2><pre>'.$err.'</pre>'; |
|
25 | 25 | // At this point, you know the call that follows will fail |
26 | 26 | } |
27 | 27 | $response = array(); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $list = scandir($serversys); |
38 | 38 | $scripts = array(); |
39 | 39 | foreach ($list as $item) { |
40 | - if (substr($item,0,1) == '.') { continue; } |
|
41 | - if (substr($item,-8)=='soap.php') { |
|
40 | + if (substr($item, 0, 1) == '.') { continue; } |
|
41 | + if (substr($item, -8) == 'soap.php') { |
|
42 | 42 | $scripts[] = $item; |
43 | 43 | } |
44 | 44 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ?> |
56 | 56 | </select><br /> |
57 | 57 | <label for="function">Function</label> |
58 | -<input type="text" name="function" value="<?php echo $function;?>"></input><br /> |
|
58 | +<input type="text" name="function" value="<?php echo $function; ?>"></input><br /> |
|
59 | 59 | <label for="param[0]">Param 0</label> |
60 | 60 | <input type="text" name="param[0]" ></input><br /> |
61 | 61 | <input type="submit" name="submit" value="Send"/> |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | 'all', |
29 | 29 | '', |
30 | 30 | array( |
31 | - 'name'=>'code' , 'type'=>'xsd:string', |
|
32 | - 'name'=>'title' , 'type'=>'xsd:string', |
|
33 | - 'name'=>'url' , 'type'=>'xsd:string', |
|
31 | + 'name'=>'code', 'type'=>'xsd:string', |
|
32 | + 'name'=>'title', 'type'=>'xsd:string', |
|
33 | + 'name'=>'url', 'type'=>'xsd:string', |
|
34 | 34 | 'name'=>'teacher', 'type'=>'xsd:string', |
35 | - 'name'=>'language','type'=>'xsd:string', |
|
35 | + 'name'=>'language', 'type'=>'xsd:string', |
|
36 | 36 | ) |
37 | 37 | ); |
38 | 38 | |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | ); |
52 | 52 | |
53 | 53 | // Register the method to expose |
54 | -$server->register('WSCourseList', // method name |
|
54 | +$server->register('WSCourseList', // method name |
|
55 | 55 | array('username' => 'xsd:string', |
56 | 56 | 'signature' => 'xsd:string', |
57 | - 'visibilities' => 'xsd:string'), // input parameters |
|
58 | - array('return' => 'xsd:Array'), // output parameters |
|
59 | - 'urn:WSCourseList', // namespace |
|
60 | - 'urn:WSCourseList#WSCourseList', // soapaction |
|
61 | - 'rpc', // style |
|
62 | - 'encoded', // use |
|
57 | + 'visibilities' => 'xsd:string'), // input parameters |
|
58 | + array('return' => 'xsd:Array'), // output parameters |
|
59 | + 'urn:WSCourseList', // namespace |
|
60 | + 'urn:WSCourseList#WSCourseList', // soapaction |
|
61 | + 'rpc', // style |
|
62 | + 'encoded', // use |
|
63 | 63 | 'This service returns a list of courses' // documentation |
64 | 64 | ); |
65 | 65 |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | 'all', |
29 | 29 | '', |
30 | 30 | array( |
31 | - 'name'=>'code' , 'type'=>'xsd:string', |
|
32 | - 'name'=>'title' , 'type'=>'xsd:string', |
|
33 | - 'name'=>'url' , 'type'=>'xsd:string', |
|
34 | - 'name'=>'teacher', 'type'=>'xsd:string', |
|
35 | - 'name'=>'language','type'=>'xsd:string', |
|
31 | + 'name'=>'code' , 'type'=>'xsd:string', |
|
32 | + 'name'=>'title' , 'type'=>'xsd:string', |
|
33 | + 'name'=>'url' , 'type'=>'xsd:string', |
|
34 | + 'name'=>'teacher', 'type'=>'xsd:string', |
|
35 | + 'name'=>'language','type'=>'xsd:string', |
|
36 | 36 | ) |
37 | 37 | ); |
38 | 38 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | // Register the method to expose |
54 | 54 | $server->register('WSCourseList', // method name |
55 | 55 | array('username' => 'xsd:string', |
56 | - 'signature' => 'xsd:string', |
|
57 | - 'visibilities' => 'xsd:string'), // input parameters |
|
56 | + 'signature' => 'xsd:string', |
|
57 | + 'visibilities' => 'xsd:string'), // input parameters |
|
58 | 58 | array('return' => 'xsd:Array'), // output parameters |
59 | 59 | 'urn:WSCourseList', // namespace |
60 | 60 | 'urn:WSCourseList#WSCourseList', // soapaction |
@@ -97,19 +97,19 @@ discard block |
||
97 | 97 | |
98 | 98 | $courses_list = array(); |
99 | 99 | |
100 | - if (!is_array($visibilities)) { |
|
101 | - $visibilities = split(',', $visibilities); |
|
102 | - } |
|
103 | - foreach ($visibilities as $visibility) { |
|
104 | - if (!in_array($visibility, array_keys($vis))) { |
|
105 | - return array('error_msg' => 'Security check failed'); |
|
106 | - } |
|
107 | - $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); |
|
108 | - foreach ($courses_list_tmp as $index => $course) { |
|
109 | - $course_info = CourseManager::get_course_information($course['code']); |
|
110 | - $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); |
|
111 | - } |
|
112 | - } |
|
100 | + if (!is_array($visibilities)) { |
|
101 | + $visibilities = split(',', $visibilities); |
|
102 | + } |
|
103 | + foreach ($visibilities as $visibility) { |
|
104 | + if (!in_array($visibility, array_keys($vis))) { |
|
105 | + return array('error_msg' => 'Security check failed'); |
|
106 | + } |
|
107 | + $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]); |
|
108 | + foreach ($courses_list_tmp as $index => $course) { |
|
109 | + $course_info = CourseManager::get_course_information($course['code']); |
|
110 | + $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); |
|
111 | + } |
|
112 | + } |
|
113 | 113 | return $courses_list; |
114 | 114 | } |
115 | 115 |
@@ -14,45 +14,45 @@ |
||
14 | 14 | */ |
15 | 15 | function import_users_from_file($filepath, $security_key) { |
16 | 16 | |
17 | - global $_configuration; |
|
18 | - |
|
19 | - $errors_returned = array( |
|
20 | - 0 => 'success', |
|
21 | - 1 => 'file import does not exist', |
|
22 | - 2 => 'no users to import', |
|
23 | - 3 => 'wrong datas in file', |
|
24 | - 4 => 'security error' |
|
25 | - ); |
|
26 | - |
|
27 | - // Check whether this script is launch by server and security key is ok. |
|
28 | - if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $_configuration['security_key']) { |
|
29 | - return $errors_returned[4]; |
|
30 | - } |
|
31 | - |
|
32 | - // Libraries |
|
33 | - require_once 'import.lib.php'; |
|
34 | - |
|
35 | - // Check is users file exists. |
|
36 | - if (!is_file($filepath)) { |
|
37 | - return $errors_returned[1]; |
|
38 | - } |
|
39 | - |
|
40 | - // Get list of users |
|
41 | - $users = parse_csv_data($filepath); |
|
42 | - if (count($users) == 0) { |
|
43 | - return $errors_returned[2]; |
|
44 | - } |
|
45 | - |
|
46 | - // Check the datas for each user |
|
47 | - $errors = validate_data($users); |
|
48 | - if (count($errors) > 0) { |
|
49 | - return $errors_returned[3]; |
|
50 | - } |
|
51 | - |
|
52 | - // Apply modifications in database |
|
53 | - save_data($users); |
|
54 | - |
|
55 | - return $errors_returned[0]; // Import successfull |
|
17 | + global $_configuration; |
|
18 | + |
|
19 | + $errors_returned = array( |
|
20 | + 0 => 'success', |
|
21 | + 1 => 'file import does not exist', |
|
22 | + 2 => 'no users to import', |
|
23 | + 3 => 'wrong datas in file', |
|
24 | + 4 => 'security error' |
|
25 | + ); |
|
26 | + |
|
27 | + // Check whether this script is launch by server and security key is ok. |
|
28 | + if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $_configuration['security_key']) { |
|
29 | + return $errors_returned[4]; |
|
30 | + } |
|
31 | + |
|
32 | + // Libraries |
|
33 | + require_once 'import.lib.php'; |
|
34 | + |
|
35 | + // Check is users file exists. |
|
36 | + if (!is_file($filepath)) { |
|
37 | + return $errors_returned[1]; |
|
38 | + } |
|
39 | + |
|
40 | + // Get list of users |
|
41 | + $users = parse_csv_data($filepath); |
|
42 | + if (count($users) == 0) { |
|
43 | + return $errors_returned[2]; |
|
44 | + } |
|
45 | + |
|
46 | + // Check the datas for each user |
|
47 | + $errors = validate_data($users); |
|
48 | + if (count($errors) > 0) { |
|
49 | + return $errors_returned[3]; |
|
50 | + } |
|
51 | + |
|
52 | + // Apply modifications in database |
|
53 | + save_data($users); |
|
54 | + |
|
55 | + return $errors_returned[0]; // Import successfull |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $server = new soap_server(); |
@@ -59,5 +59,5 @@ |
||
59 | 59 | |
60 | 60 | $server->register('import_users_from_file'); |
61 | 61 | |
62 | -$http_request = (isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:''); |
|
62 | +$http_request = (isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''); |
|
63 | 63 | $server->service($http_request); |
@@ -3,132 +3,132 @@ discard block |
||
3 | 3 | * Validates imported data. |
4 | 4 | */ |
5 | 5 | function validate_data($users) { |
6 | - global $defined_auth_sources; |
|
7 | - $errors = array (); |
|
8 | - $usernames = array (); |
|
9 | - if(is_array($users)) { |
|
10 | - foreach ($users as $index => $user) { |
|
11 | - // 1. Check whether mandatory fields have been set. |
|
12 | - $mandatory_fields = array ('LastName', 'FirstName'); |
|
13 | - if (api_get_setting('registration', 'email') == 'true') { |
|
14 | - $mandatory_fields[] = 'Email'; |
|
15 | - } |
|
16 | - foreach ($mandatory_fields as $key => $field) { |
|
17 | - if (!isset ($user[$field]) || strlen($user[$field]) == 0) { |
|
18 | - $user['error'] = get_lang($field.'Mandatory'); |
|
19 | - $errors[] = $user; |
|
20 | - } |
|
21 | - } |
|
22 | - // 2. Check username. |
|
23 | - if (!UserManager::is_username_empty($user['UserName'])) { |
|
24 | - // 2.1. Check whether username was used twice in the import file. |
|
25 | - if (isset($usernames[$user['UserName']])) { |
|
26 | - $user['error'] = get_lang('UserNameUsedTwice'); |
|
27 | - $errors[] = $user; |
|
28 | - } |
|
29 | - $usernames[$user['UserName']] = 1; |
|
30 | - // 2.2. Check whether username is allready in use in database. |
|
31 | - if (!UserManager::is_username_available($user['UserName'])) { |
|
32 | - $user['error'] = get_lang('UserNameNotAvailable'); |
|
33 | - $errors[] = $user; |
|
34 | - } |
|
35 | - // 2.3. Check whether username is too long. |
|
36 | - if (UserManager::is_username_too_long($user['UserName'])) { |
|
37 | - $user['error'] = get_lang('UserNameTooLong'); |
|
38 | - $errors[] = $user; |
|
39 | - } |
|
40 | - } |
|
41 | - // 3. Check status. |
|
42 | - if (isset ($user['Status']) && !api_status_exists($user['Status'])) { |
|
43 | - $user['error'] = get_lang('WrongStatus'); |
|
44 | - $errors[] = $user; |
|
45 | - } |
|
46 | - // 4. Check classname. |
|
47 | - if (isset ($user['ClassName']) && strlen($user['ClassName']) != 0) { |
|
48 | - if (!ClassManager :: class_name_exists($user['ClassName'])) { |
|
49 | - $user['error'] = get_lang('ClassNameNotAvailable'); |
|
50 | - $errors[] = $user; |
|
51 | - } |
|
52 | - } |
|
53 | - // 5. Check authentication source. |
|
54 | - if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) { |
|
55 | - if (!in_array($user['AuthSource'], $defined_auth_sources)) { |
|
56 | - $user['error'] = get_lang('AuthSourceNotAvailable'); |
|
57 | - $errors[] = $user; |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
62 | - return $errors; |
|
6 | + global $defined_auth_sources; |
|
7 | + $errors = array (); |
|
8 | + $usernames = array (); |
|
9 | + if(is_array($users)) { |
|
10 | + foreach ($users as $index => $user) { |
|
11 | + // 1. Check whether mandatory fields have been set. |
|
12 | + $mandatory_fields = array ('LastName', 'FirstName'); |
|
13 | + if (api_get_setting('registration', 'email') == 'true') { |
|
14 | + $mandatory_fields[] = 'Email'; |
|
15 | + } |
|
16 | + foreach ($mandatory_fields as $key => $field) { |
|
17 | + if (!isset ($user[$field]) || strlen($user[$field]) == 0) { |
|
18 | + $user['error'] = get_lang($field.'Mandatory'); |
|
19 | + $errors[] = $user; |
|
20 | + } |
|
21 | + } |
|
22 | + // 2. Check username. |
|
23 | + if (!UserManager::is_username_empty($user['UserName'])) { |
|
24 | + // 2.1. Check whether username was used twice in the import file. |
|
25 | + if (isset($usernames[$user['UserName']])) { |
|
26 | + $user['error'] = get_lang('UserNameUsedTwice'); |
|
27 | + $errors[] = $user; |
|
28 | + } |
|
29 | + $usernames[$user['UserName']] = 1; |
|
30 | + // 2.2. Check whether username is allready in use in database. |
|
31 | + if (!UserManager::is_username_available($user['UserName'])) { |
|
32 | + $user['error'] = get_lang('UserNameNotAvailable'); |
|
33 | + $errors[] = $user; |
|
34 | + } |
|
35 | + // 2.3. Check whether username is too long. |
|
36 | + if (UserManager::is_username_too_long($user['UserName'])) { |
|
37 | + $user['error'] = get_lang('UserNameTooLong'); |
|
38 | + $errors[] = $user; |
|
39 | + } |
|
40 | + } |
|
41 | + // 3. Check status. |
|
42 | + if (isset ($user['Status']) && !api_status_exists($user['Status'])) { |
|
43 | + $user['error'] = get_lang('WrongStatus'); |
|
44 | + $errors[] = $user; |
|
45 | + } |
|
46 | + // 4. Check classname. |
|
47 | + if (isset ($user['ClassName']) && strlen($user['ClassName']) != 0) { |
|
48 | + if (!ClassManager :: class_name_exists($user['ClassName'])) { |
|
49 | + $user['error'] = get_lang('ClassNameNotAvailable'); |
|
50 | + $errors[] = $user; |
|
51 | + } |
|
52 | + } |
|
53 | + // 5. Check authentication source. |
|
54 | + if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) { |
|
55 | + if (!in_array($user['AuthSource'], $defined_auth_sources)) { |
|
56 | + $user['error'] = get_lang('AuthSourceNotAvailable'); |
|
57 | + $errors[] = $user; |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | + return $errors; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Adds missing user-information (which isn't required, like password, username, etc). |
67 | 67 | */ |
68 | 68 | function complete_missing_data($user) { |
69 | - // 1. Create a username if necessary. |
|
70 | - if (UserManager::is_username_empty($user['UserName'])) { |
|
71 | - $user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']); |
|
72 | - } |
|
73 | - // 2. Generate a password if necessary. |
|
74 | - if (!isset ($user['Password']) || strlen($user['Password']) == 0) { |
|
75 | - $user['Password'] = api_generate_password(); |
|
76 | - } |
|
77 | - // 3. set status if not allready set. |
|
78 | - if (!isset ($user['Status']) || strlen($user['Status']) == 0) { |
|
79 | - $user['Status'] = 'user'; |
|
80 | - } |
|
81 | - // 4. Set authsource if not allready set. |
|
82 | - if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) { |
|
83 | - $user['AuthSource'] = PLATFORM_AUTH_SOURCE; |
|
84 | - } |
|
85 | - return $user; |
|
69 | + // 1. Create a username if necessary. |
|
70 | + if (UserManager::is_username_empty($user['UserName'])) { |
|
71 | + $user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']); |
|
72 | + } |
|
73 | + // 2. Generate a password if necessary. |
|
74 | + if (!isset ($user['Password']) || strlen($user['Password']) == 0) { |
|
75 | + $user['Password'] = api_generate_password(); |
|
76 | + } |
|
77 | + // 3. set status if not allready set. |
|
78 | + if (!isset ($user['Status']) || strlen($user['Status']) == 0) { |
|
79 | + $user['Status'] = 'user'; |
|
80 | + } |
|
81 | + // 4. Set authsource if not allready set. |
|
82 | + if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) { |
|
83 | + $user['AuthSource'] = PLATFORM_AUTH_SOURCE; |
|
84 | + } |
|
85 | + return $user; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Save the imported data |
90 | 90 | */ |
91 | 91 | function save_data($users) { |
92 | - $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
|
93 | - if(is_array($users)) { |
|
94 | - foreach ($users as $index => $user) { |
|
95 | - $user = complete_missing_data($user); |
|
92 | + $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
|
93 | + if(is_array($users)) { |
|
94 | + foreach ($users as $index => $user) { |
|
95 | + $user = complete_missing_data($user); |
|
96 | 96 | |
97 | - $user['Status'] = api_status_key($user['Status']); |
|
97 | + $user['Status'] = api_status_key($user['Status']); |
|
98 | 98 | |
99 | - $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
|
100 | - foreach ($user['Courses'] as $index => $course) { |
|
101 | - if(CourseManager :: course_exists($course)) |
|
102 | - CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
103 | - } |
|
104 | - if (strlen($user['ClassName']) > 0) { |
|
105 | - $class_id = ClassManager :: get_class_id($user['ClassName']); |
|
106 | - ClassManager :: add_user($user_id, $class_id); |
|
107 | - } |
|
99 | + $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
|
100 | + foreach ($user['Courses'] as $index => $course) { |
|
101 | + if(CourseManager :: course_exists($course)) |
|
102 | + CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
103 | + } |
|
104 | + if (strlen($user['ClassName']) > 0) { |
|
105 | + $class_id = ClassManager :: get_class_id($user['ClassName']); |
|
106 | + ClassManager :: add_user($user_id, $class_id); |
|
107 | + } |
|
108 | 108 | |
109 | - // TODO: Hard-coded French texts. |
|
109 | + // TODO: Hard-coded French texts. |
|
110 | 110 | |
111 | - // Qualite |
|
112 | - if (!empty($user['Qualite'])) { |
|
113 | - UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']); |
|
114 | - } |
|
111 | + // Qualite |
|
112 | + if (!empty($user['Qualite'])) { |
|
113 | + UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']); |
|
114 | + } |
|
115 | 115 | |
116 | - // Categorie |
|
117 | - if (!empty($user['Categorie'])) { |
|
118 | - UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']); |
|
119 | - } |
|
116 | + // Categorie |
|
117 | + if (!empty($user['Categorie'])) { |
|
118 | + UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']); |
|
119 | + } |
|
120 | 120 | |
121 | - // Etat |
|
122 | - if (!empty($user['Etat'])) { |
|
123 | - UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']); |
|
124 | - } |
|
121 | + // Etat |
|
122 | + if (!empty($user['Etat'])) { |
|
123 | + UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']); |
|
124 | + } |
|
125 | 125 | |
126 | - // Niveau |
|
127 | - if (!empty($user['Niveau'])) { |
|
128 | - UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']); |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
126 | + // Niveau |
|
127 | + if (!empty($user['Niveau'])) { |
|
128 | + UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']); |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | * @return array All userinformation read from the file |
138 | 138 | */ |
139 | 139 | function parse_csv_data($file) { |
140 | - $users = Import :: csvToArray($file); |
|
141 | - foreach ($users as $index => $user) { |
|
142 | - if (isset ($user['Courses'])) { |
|
143 | - $user['Courses'] = explode('|', trim($user['Courses'])); |
|
144 | - } |
|
145 | - $users[$index] = $user; |
|
146 | - } |
|
147 | - return $users; |
|
140 | + $users = Import :: csvToArray($file); |
|
141 | + foreach ($users as $index => $user) { |
|
142 | + if (isset ($user['Courses'])) { |
|
143 | + $user['Courses'] = explode('|', trim($user['Courses'])); |
|
144 | + } |
|
145 | + $users[$index] = $user; |
|
146 | + } |
|
147 | + return $users; |
|
148 | 148 | } |
@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | */ |
5 | 5 | function validate_data($users) { |
6 | 6 | global $defined_auth_sources; |
7 | - $errors = array (); |
|
8 | - $usernames = array (); |
|
9 | - if(is_array($users)) { |
|
7 | + $errors = array(); |
|
8 | + $usernames = array(); |
|
9 | + if (is_array($users)) { |
|
10 | 10 | foreach ($users as $index => $user) { |
11 | 11 | // 1. Check whether mandatory fields have been set. |
12 | - $mandatory_fields = array ('LastName', 'FirstName'); |
|
12 | + $mandatory_fields = array('LastName', 'FirstName'); |
|
13 | 13 | if (api_get_setting('registration', 'email') == 'true') { |
14 | 14 | $mandatory_fields[] = 'Email'; |
15 | 15 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function save_data($users) { |
92 | 92 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
93 | - if(is_array($users)) { |
|
93 | + if (is_array($users)) { |
|
94 | 94 | foreach ($users as $index => $user) { |
95 | 95 | $user = complete_missing_data($user); |
96 | 96 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | |
99 | 99 | $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
100 | 100 | foreach ($user['Courses'] as $index => $course) { |
101 | - if(CourseManager :: course_exists($course)) |
|
102 | - CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
101 | + if (CourseManager :: course_exists($course)) |
|
102 | + CourseManager :: subscribe_user($user_id, $course, $user['Status']); |
|
103 | 103 | } |
104 | 104 | if (strlen($user['ClassName']) > 0) { |
105 | 105 | $class_id = ClassManager :: get_class_id($user['ClassName']); |
@@ -98,8 +98,9 @@ |
||
98 | 98 | |
99 | 99 | $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']); |
100 | 100 | foreach ($user['Courses'] as $index => $course) { |
101 | - if(CourseManager :: course_exists($course)) |
|
102 | - CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
101 | + if(CourseManager :: course_exists($course)) { |
|
102 | + CourseManager :: subscribe_user($user_id, $course,$user['Status']); |
|
103 | + } |
|
103 | 104 | } |
104 | 105 | if (strlen($user['ClassName']) > 0) { |
105 | 106 | $class_id = ClassManager :: get_class_id($user['ClassName']); |