@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | $coachStartDate = null; |
55 | 55 | if (!empty($nb_days_access_before)) { |
56 | 56 | $day = intval($nb_days_access_before); |
57 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
57 | + $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days')); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $coachEndDate = null; |
61 | 61 | if (!empty($nb_days_access_after)) { |
62 | 62 | $day = intval($nb_days_access_after); |
63 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
63 | + $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Try to create the session |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | 0, |
77 | 77 | $visibility |
78 | 78 | ); |
79 | - if(!is_int($session_id)) { |
|
79 | + if (!is_int($session_id)) { |
|
80 | 80 | return new WSError(301, 'Could not create the session'); |
81 | 81 | } else { |
82 | 82 | // Add the Original session id to the extra fields |
83 | 83 | $extras_associative = array(); |
84 | - if($session_id_field_name != "chamilo_session_id") { |
|
84 | + if ($session_id_field_name != "chamilo_session_id") { |
|
85 | 85 | $extras_associative[$session_id_field_name] = $session_id_value; |
86 | 86 | } |
87 | - foreach($extras as $extra) { |
|
87 | + foreach ($extras as $extra) { |
|
88 | 88 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
89 | 89 | } |
90 | 90 | // Create the extra fields |
91 | - foreach($extras_associative as $fname => $fvalue) { |
|
91 | + foreach ($extras_associative as $fname => $fvalue) { |
|
92 | 92 | SessionManager::create_session_extra_field($fname, 1, $fname); |
93 | 93 | SessionManager::update_session_extra_field_value( |
94 | 94 | $session_id, |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
122 | 122 | $verifKey = $this->verifyKey($secret_key); |
123 | - if($verifKey instanceof WSError) { |
|
123 | + if ($verifKey instanceof WSError) { |
|
124 | 124 | $this->handleError($verifKey); |
125 | 125 | } else { |
126 | 126 | $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
127 | - if($session_id instanceof WSError) { |
|
127 | + if ($session_id instanceof WSError) { |
|
128 | 128 | $this->handleError($session_id); |
129 | 129 | } else { |
130 | 130 | return $session_id; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function deleteSessionHelper($session_id_field_name, $session_id_value) { |
143 | 143 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
144 | - if($session_id instanceof WSError) { |
|
144 | + if ($session_id instanceof WSError) { |
|
145 | 145 | return $session_id; |
146 | 146 | } else { |
147 | 147 | SessionManager::delete($session_id, true); |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) { |
160 | 160 | $verifKey = $this->verifyKey($secret_key); |
161 | - if($verifKey instanceof WSError) { |
|
161 | + if ($verifKey instanceof WSError) { |
|
162 | 162 | $this->handleError($verifKey); |
163 | 163 | } else { |
164 | 164 | $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value); |
165 | - if($result instanceof WSError) { |
|
165 | + if ($result instanceof WSError) { |
|
166 | 166 | $this->handleError($result); |
167 | 167 | } |
168 | 168 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $extras |
201 | 201 | ) { |
202 | 202 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
203 | - if($session_id instanceof WSError) { |
|
203 | + if ($session_id instanceof WSError) { |
|
204 | 204 | return $session_id; |
205 | 205 | } else { |
206 | 206 | // Verify that coach exists and get its id |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $coachStartDate = null; |
213 | 213 | if (!empty($nb_days_access_before)) { |
214 | 214 | $day = intval($nb_days_access_before); |
215 | - $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days')); |
|
215 | + $coachStartDate = date('Y-m-d ', strtotime($start_date.' + '.$day.' days')); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | $coachEndDate = null; |
219 | 219 | if (!empty($nb_days_access_after)) { |
220 | 220 | $day = intval($nb_days_access_after); |
221 | - $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days')); |
|
221 | + $coachEndDate = date('Y-m-d ', strtotime($end_date.' + '.$day.' days')); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $result_id = SessionManager::edit_session( |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | $coachEndDate, |
233 | 233 | $user_id, |
234 | 234 | 0, |
235 | - (int)$visibility |
|
235 | + (int) $visibility |
|
236 | 236 | ); |
237 | - if(!is_int($result_id)) { |
|
237 | + if (!is_int($result_id)) { |
|
238 | 238 | return new WSError(302, 'Could not edit the session'); |
239 | 239 | } else { |
240 | - if(!empty($extras)) { |
|
240 | + if (!empty($extras)) { |
|
241 | 241 | $extras_associative = array(); |
242 | - foreach($extras as $extra) { |
|
242 | + foreach ($extras as $extra) { |
|
243 | 243 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
244 | 244 | } |
245 | 245 | // Create the extra fields |
246 | - foreach($extras_associative as $fname => $fvalue) { |
|
246 | + foreach ($extras_associative as $fname => $fvalue) { |
|
247 | 247 | SessionManager::create_session_extra_field($fname, 1, $fname); |
248 | 248 | SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue); |
249 | 249 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) { |
274 | 274 | $verifKey = $this->verifyKey($secret_key); |
275 | - if($verifKey instanceof WSError) { |
|
275 | + if ($verifKey instanceof WSError) { |
|
276 | 276 | $this->handleError($verifKey); |
277 | 277 | } else { |
278 | 278 | $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras); |
279 | - if($session_id_value instanceof WSError) { |
|
279 | + if ($session_id_value instanceof WSError) { |
|
280 | 280 | $this->handleError($result); |
281 | 281 | } |
282 | 282 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) { |
296 | 296 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
297 | - if($session_id instanceof WSError) { |
|
297 | + if ($session_id instanceof WSError) { |
|
298 | 298 | return $session_id; |
299 | 299 | } else { |
300 | 300 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
301 | - if($user_id instanceof WSError) { |
|
301 | + if ($user_id instanceof WSError) { |
|
302 | 302 | return $user_id; |
303 | 303 | } else { |
304 | - if($state == 1) { |
|
304 | + if ($state == 1) { |
|
305 | 305 | SessionManager::suscribe_users_to_session($session_id, array($user_id)); |
306 | 306 | } else { |
307 | 307 | $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
327 | 327 | $verifKey = $this->verifyKey($secret_key); |
328 | - if($verifKey instanceof WSError) { |
|
328 | + if ($verifKey instanceof WSError) { |
|
329 | 329 | $this->handleError($verifKey); |
330 | 330 | } else { |
331 | 331 | $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1); |
332 | - if($result instanceof WSError) { |
|
332 | + if ($result instanceof WSError) { |
|
333 | 333 | $this->handleError($result); |
334 | 334 | } |
335 | 335 | } |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) { |
348 | 348 | $verifKey = $this->verifyKey($secret_key); |
349 | - if($verifKey instanceof WSError) { |
|
349 | + if ($verifKey instanceof WSError) { |
|
350 | 350 | $this->handleError($verifKey); |
351 | 351 | } else { |
352 | 352 | $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0); |
353 | - if($result instanceof WSError) { |
|
353 | + if ($result instanceof WSError) { |
|
354 | 354 | $this->handleError($result); |
355 | 355 | } |
356 | 356 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | if ($state == 1) { |
386 | 386 | SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id); |
387 | 387 | } else { |
388 | - $user_id = array (0 => $user_id); |
|
388 | + $user_id = array(0 => $user_id); |
|
389 | 389 | $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id); |
390 | 390 | if (!$result) { |
391 | 391 | return new WSError(303, 'There was an error unsubscribing this Teacher from the session'); |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | */ |
458 | 458 | protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) { |
459 | 459 | $session_id = $this->getSessionId($session_id_field_name, $session_id_value); |
460 | - if($session_id instanceof WSError) { |
|
460 | + if ($session_id instanceof WSError) { |
|
461 | 461 | return $session_id; |
462 | 462 | } else { |
463 | 463 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
464 | - if($course_id instanceof WSError) { |
|
464 | + if ($course_id instanceof WSError) { |
|
465 | 465 | return $course_id; |
466 | 466 | } else { |
467 | - if($state == 1) { |
|
467 | + if ($state == 1) { |
|
468 | 468 | SessionManager::add_courses_to_session($session_id, array($course_id)); |
469 | 469 | return true; |
470 | 470 | } else { |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
492 | 492 | $verifKey = $this->verifyKey($secret_key); |
493 | - if($verifKey instanceof WSError) { |
|
493 | + if ($verifKey instanceof WSError) { |
|
494 | 494 | $this->handleError($verifKey); |
495 | 495 | } else { |
496 | 496 | $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1); |
497 | - if($result instanceof WSError) { |
|
497 | + if ($result instanceof WSError) { |
|
498 | 498 | $this->handleError($result); |
499 | 499 | } |
500 | 500 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | */ |
512 | 512 | public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { |
513 | 513 | $verifKey = $this->verifyKey($secret_key); |
514 | - if($verifKey instanceof WSError) { |
|
514 | + if ($verifKey instanceof WSError) { |
|
515 | 515 | $this->handleError($verifKey); |
516 | 516 | } else { |
517 | 517 | $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0); |
518 | - if($result instanceof WSError) { |
|
518 | + if ($result instanceof WSError) { |
|
519 | 519 | $this->handleError($result); |
520 | 520 | } |
521 | 521 | } |
@@ -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 | /* |
@@ -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 |
@@ -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); |
@@ -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']); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function get_announcements_id($username, $password, $course_code) |
17 | 17 | { |
18 | - if($this->verifyUserPass($username, $password) == "valid") |
|
18 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
19 | 19 | { |
20 | 20 | |
21 | 21 | $result = self::get_announcements($username, $course_code); |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | |
34 | 34 | public function get_announcement_data($username, $password, $course_code, $announcement_id, $field) |
35 | 35 | { |
36 | - if($this->verifyUserPass($username, $password) == "valid") |
|
36 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
37 | 37 | { |
38 | 38 | $htmlcode = false; |
39 | 39 | $user_id = UserManager::get_user_id_from_username($username); |
40 | 40 | |
41 | 41 | $result = self::get_announcements($username, $course_code, $announcement_id); |
42 | - while($announcement = Database::fetch_array($result)) |
|
42 | + while ($announcement = Database::fetch_array($result)) |
|
43 | 43 | { |
44 | 44 | $announcements[] = $announcement; |
45 | 45 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | return (htmlcode) ? html_entity_decode($announcements[0][$field_table]) : $announcements[0][$field_table]; |
71 | 71 | |
72 | - }else |
|
72 | + } else |
|
73 | 73 | return get_lang('InvalidId'); |
74 | 74 | } |
75 | 75 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | $announcement_id = ($announcement_id == 0) ? "" : "AND announcement.id=".$announcement_id; |
83 | 83 | $user_id = UserManager::get_user_id_from_username($username); |
84 | 84 | $course_info = CourseManager::get_course_information($course_code); |
85 | - $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
86 | - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
87 | - $maximum = '12'; |
|
85 | + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
86 | + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
87 | + $maximum = '12'; |
|
88 | 88 | |
89 | - $group_memberships=GroupManager::get_group_ids($course_info['real_id'], $user_id); |
|
89 | + $group_memberships = GroupManager::get_group_ids($course_info['real_id'], $user_id); |
|
90 | 90 | |
91 | 91 | if (api_get_group_id() == 0) { |
92 | 92 | $cond_user_id = " AND ( |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | |
105 | 105 | // the user is member of several groups => display personal |
106 | 106 | // announcements AND his group announcements AND the general announcements |
107 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
108 | - $sql="SELECT |
|
107 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
108 | + $sql = "SELECT |
|
109 | 109 | announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
110 | 110 | FROM $tbl_announcement announcement, $tbl_item_property ip |
111 | 111 | WHERE |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
21 | 21 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
22 | - if($course_id instanceof WSCMError) { |
|
22 | + if ($course_id instanceof WSCMError) { |
|
23 | 23 | return $course_id; |
24 | 24 | } else { |
25 | 25 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
39 | 39 | $verifKey = $this->verifyKey($secret_key); |
40 | - if($verifKey instanceof WSError) { |
|
40 | + if ($verifKey instanceof WSError) { |
|
41 | 41 | $this->handleError($verifKey); |
42 | 42 | } else { |
43 | 43 | $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
44 | - if($result instanceof WSError) { |
|
44 | + if ($result instanceof WSError) { |
|
45 | 45 | $this->handleError($result); |
46 | 46 | } |
47 | 47 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function DeleteCourses($secret_key, $courses) { |
59 | 59 | $verifKey = $this->verifyKey($secret_key); |
60 | - if($verifKey instanceof WSError) { |
|
60 | + if ($verifKey instanceof WSError) { |
|
61 | 61 | $this->handleError($verifKey); |
62 | 62 | } else { |
63 | 63 | $results = array(); |
64 | - foreach($courses as $course) { |
|
64 | + foreach ($courses as $course) { |
|
65 | 65 | $result_tmp = array(); |
66 | 66 | $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
67 | 67 | $result_tmp['course_id_value'] = $course['course_id_value']; |
68 | - if($result_op instanceof WSCMError) { |
|
68 | + if ($result_op instanceof WSCMError) { |
|
69 | 69 | // Return the error in the results |
70 | 70 | $result_tmp['result'] = $result_op->toArray(); |
71 | 71 | } else { |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
96 | 96 | // Add the original course id field name and value to the extra fields if needed |
97 | 97 | $extras_associative = array(); |
98 | - if($course_id_field_name != "chamilo_course_id") { |
|
98 | + if ($course_id_field_name != "chamilo_course_id") { |
|
99 | 99 | $extras_associative[$course_id_field_name] = $course_id_value; |
100 | 100 | } |
101 | - foreach($extras as $extra) { |
|
101 | + foreach ($extras as $extra) { |
|
102 | 102 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
103 | 103 | } |
104 | 104 | $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
105 | - if($course_admin_id instanceof WSError) { |
|
105 | + if ($course_admin_id instanceof WSError) { |
|
106 | 106 | return $course_admin_id; |
107 | 107 | } |
108 | - if($wanted_code == '') { |
|
108 | + if ($wanted_code == '') { |
|
109 | 109 | $wanted_code = CourseManager::generate_course_code($title); |
110 | 110 | } |
111 | 111 | $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return new WSError(202, 'There was an error creating the course'); |
114 | 114 | } else { |
115 | 115 | // Update extra fields |
116 | - foreach($extras_associative as $fname => $fvalue) { |
|
116 | + foreach ($extras_associative as $fname => $fvalue) { |
|
117 | 117 | CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
118 | 118 | } |
119 | 119 | // Get course id |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) { |
142 | 142 | // First, verify the secret key |
143 | 143 | $verifKey = $this->verifyKey($secret_key); |
144 | - if($verifKey instanceof WSError) { |
|
144 | + if ($verifKey instanceof WSError) { |
|
145 | 145 | $this->handleError($verifKey); |
146 | 146 | } else { |
147 | 147 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
148 | - if($result instanceof WSError) { |
|
148 | + if ($result instanceof WSError) { |
|
149 | 149 | $this->handleError($result); |
150 | 150 | } else { |
151 | 151 | return $result; |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | public function CreateCourses($secret_key, $courses) { |
164 | 164 | // First, verify the secret key |
165 | 165 | $verifKey = $this->verifyKey($secret_key); |
166 | - if($verifKey instanceof WSCMError) { |
|
166 | + if ($verifKey instanceof WSCMError) { |
|
167 | 167 | $this->handleError($verifKey); |
168 | 168 | } else { |
169 | 169 | $results = array(); |
170 | - foreach($courses as $course) { |
|
170 | + foreach ($courses as $course) { |
|
171 | 171 | $result_tmp = array(); |
172 | 172 | //reinitialize variables just in case |
173 | 173 | $title = $category_code = $wanted_code = $tutor_name = $course_admin_user_id_field_name = $course_admin_user_id_value = $language = $course_id_field_name = $course_id_value = $extras = null; |
174 | 174 | extract($course); |
175 | 175 | $result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras); |
176 | - if($result instanceof WSCMError) { |
|
176 | + if ($result instanceof WSCMError) { |
|
177 | 177 | $result_tmp['result'] = $result->toArray(); |
178 | 178 | $result_tmp['course_id_value'] = $course_id_value; |
179 | 179 | $result_tmp['course_id_generated'] = 0; |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
209 | 209 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
210 | - if($course_id instanceof WSCMError) { |
|
210 | + if ($course_id instanceof WSCMError) { |
|
211 | 211 | return $course_id; |
212 | 212 | } else { |
213 | 213 | $attributes = array(); |
214 | - if(!is_empty($title)) { |
|
214 | + if (!is_empty($title)) { |
|
215 | 215 | $attributes['title'] = $title; |
216 | 216 | } |
217 | - if(!is_empty($category_code)) { |
|
217 | + if (!is_empty($category_code)) { |
|
218 | 218 | $attributes['category_code'] = $category_code; |
219 | 219 | } |
220 | - if(!is_empty($department_name)) { |
|
220 | + if (!is_empty($department_name)) { |
|
221 | 221 | $attributes['department_name'] = $department_name; |
222 | 222 | } |
223 | - if(!is_empty($department_url)) { |
|
223 | + if (!is_empty($department_url)) { |
|
224 | 224 | $attributes['department_url'] = $department_url; |
225 | 225 | } |
226 | - if(!is_empty($language)) { |
|
226 | + if (!is_empty($language)) { |
|
227 | 227 | $attributes['course_language'] = $language; |
228 | 228 | } |
229 | - if($visibility != '') { |
|
230 | - $attributes['visibility'] = (int)$visibility; |
|
229 | + if ($visibility != '') { |
|
230 | + $attributes['visibility'] = (int) $visibility; |
|
231 | 231 | } |
232 | - if($subscribe != '') { |
|
233 | - $attributes['subscribe'] = (int)$subscribe; |
|
232 | + if ($subscribe != '') { |
|
233 | + $attributes['subscribe'] = (int) $subscribe; |
|
234 | 234 | } |
235 | - if($unsubscribe != '') { |
|
236 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
235 | + if ($unsubscribe != '') { |
|
236 | + $attributes['unsubscribe'] = (int) $unsubscribe; |
|
237 | 237 | } |
238 | - if(!is_empty($visual_code)) { |
|
238 | + if (!is_empty($visual_code)) { |
|
239 | 239 | $attributes['visual_code'] = $visual_code; |
240 | 240 | } |
241 | - if(!is_empty($attributes)) { |
|
241 | + if (!is_empty($attributes)) { |
|
242 | 242 | CourseManager::update_attributes($course_id, $attributes); |
243 | 243 | } |
244 | - if(!empty($extras)) { |
|
244 | + if (!empty($extras)) { |
|
245 | 245 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
246 | 246 | $extras_associative = array(); |
247 | - foreach($extras as $extra) { |
|
247 | + foreach ($extras as $extra) { |
|
248 | 248 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
249 | 249 | } |
250 | - foreach($extras_associative as $fname => $fvalue) { |
|
250 | + foreach ($extras_associative as $fname => $fvalue) { |
|
251 | 251 | CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
252 | 252 | } |
253 | 253 | } |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function EditCourse($secret_key, $course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
276 | 276 | $verifKey = $this->verifyKey($secret_key); |
277 | - if($verifKey instanceof WSCMError) { |
|
277 | + if ($verifKey instanceof WSCMError) { |
|
278 | 278 | $this->handleError($verifKey); |
279 | 279 | } else { |
280 | 280 | $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
281 | - if($result instanceof WSCMError) { |
|
281 | + if ($result instanceof WSCMError) { |
|
282 | 282 | $this->handleError($result); |
283 | 283 | } |
284 | 284 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function ListCourses($secret_key, $course_id_field_name) { |
296 | 296 | $verifKey = $this->verifyKey($secret_key); |
297 | - if($verifKey instanceof WSError) { |
|
297 | + if ($verifKey instanceof WSError) { |
|
298 | 298 | $this->handleError($verifKey); |
299 | 299 | } else { |
300 | 300 | $courses_result = array(); |
301 | 301 | $category_names = array(); |
302 | 302 | |
303 | 303 | $courses = CourseManager::get_courses_list(); |
304 | - foreach($courses as $course) { |
|
304 | + foreach ($courses as $course) { |
|
305 | 305 | $course_tmp = array(); |
306 | 306 | $course_tmp['id'] = $course['id']; |
307 | 307 | $course_tmp['code'] = $course['code']; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $course_tmp['visibility'] = $course['visibility']; |
311 | 311 | |
312 | 312 | // Determining category name |
313 | - if($category_names[$course['category_code']]) { |
|
313 | + if ($category_names[$course['category_code']]) { |
|
314 | 314 | $course_tmp['category_name'] = $category_names[$course['category_code']]; |
315 | 315 | } else { |
316 | 316 | $category = CourseManager::get_course_category($course['category_code']); |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | */ |
347 | 347 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
348 | 348 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
349 | - if($course_id instanceof WSError) { |
|
349 | + if ($course_id instanceof WSError) { |
|
350 | 350 | return $course_id; |
351 | 351 | } else { |
352 | 352 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
353 | - if($user_id instanceof WSError) { |
|
353 | + if ($user_id instanceof WSError) { |
|
354 | 354 | return $user_id; |
355 | 355 | } else { |
356 | 356 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
357 | - if($state == 0) { |
|
357 | + if ($state == 0) { |
|
358 | 358 | // Unsubscribe user |
359 | 359 | CourseManager::unsubscribe_user($user_id, $course_code); |
360 | 360 | return true; |
361 | 361 | } else { |
362 | 362 | // Subscribe user |
363 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
363 | + if (CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
364 | 364 | return true; |
365 | 365 | } else { |
366 | 366 | return new WSError(203, 'An error occured subscribing to this course'); |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
384 | 384 | $verifKey = $this->verifyKey($secret_key); |
385 | - if($verifKey instanceof WSError) { |
|
385 | + if ($verifKey instanceof WSError) { |
|
386 | 386 | $this->handleError($verifKey); |
387 | 387 | } else { |
388 | 388 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
389 | - if($result instanceof WSError) { |
|
389 | + if ($result instanceof WSError) { |
|
390 | 390 | $this->handleError($result); |
391 | 391 | } |
392 | 392 | } |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
405 | 405 | $verifKey = $this->verifyKey($secret_key); |
406 | - if($verifKey instanceof WSError) { |
|
406 | + if ($verifKey instanceof WSError) { |
|
407 | 407 | $this->handleError($verifKey); |
408 | 408 | } else { |
409 | 409 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
410 | - if($result instanceof WSError) { |
|
410 | + if ($result instanceof WSError) { |
|
411 | 411 | $this->handleError($result); |
412 | 412 | } |
413 | 413 | } |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
425 | 425 | $verifKey = $this->verifyKey($secret_key); |
426 | - if($verifKey instanceof WSError) { |
|
426 | + if ($verifKey instanceof WSError) { |
|
427 | 427 | $this->handleError($verifKey); |
428 | 428 | } else { |
429 | 429 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
430 | - if($course_id instanceof WSError) { |
|
430 | + if ($course_id instanceof WSError) { |
|
431 | 431 | return $course_id; |
432 | 432 | } else { |
433 | 433 | // Course exists, get its descriptions |
434 | 434 | $descriptions = CourseDescription::get_descriptions($course_id); |
435 | 435 | $results = array(); |
436 | - foreach($descriptions as $description) { |
|
436 | + foreach ($descriptions as $description) { |
|
437 | 437 | $results[] = array('course_desc_id' => $description->get_description_type(), |
438 | 438 | 'course_desc_title' => $description->get_title(), |
439 | 439 | 'course_desc_content' => $description->get_content()); |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | */ |
457 | 457 | public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
458 | 458 | $verifKey = $this->verifyKey($secret_key); |
459 | - if($verifKey instanceof WSError) { |
|
459 | + if ($verifKey instanceof WSError) { |
|
460 | 460 | $this->handleError($verifKey); |
461 | 461 | } else { |
462 | 462 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
463 | - if($course_id instanceof WSError) { |
|
463 | + if ($course_id instanceof WSError) { |
|
464 | 464 | return $course_id; |
465 | 465 | } else { |
466 | 466 | // Create the new course description |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | // Check if this course description exists |
478 | 478 | $descriptions = CourseDescription::get_descriptions($course_id); |
479 | 479 | $exists = false; |
480 | - foreach($descriptions as $description) { |
|
481 | - if($description->get_description_type() == $course_desc_id) { |
|
480 | + foreach ($descriptions as $description) { |
|
481 | + if ($description->get_description_type() == $course_desc_id) { |
|
482 | 482 | $exists = true; |
483 | 483 | } |
484 | 484 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | } |
495 | 495 | public function unreadMessage($username, $password) |
496 | 496 | { |
497 | - if($this->verifyUserPass($username, $password) == "valid") |
|
497 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
498 | 498 | { |
499 | 499 | $table_message = Database::get_main_table(TABLE_MESSAGE); |
500 | 500 | $user_id = UserManager::get_user_id_from_username($username); |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | public function get_message_data($username, $password) |
513 | 513 | { |
514 | - if($this->verifyUserPass($username, $password) == "valid") |
|
514 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
515 | 515 | { |
516 | 516 | $user_id = get_user_id_from_username($username); |
517 | 517 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | public function nada($username, $password) |
523 | 523 | { |
524 | - if($this->verifyUserPass($username, $password) == "valid") |
|
524 | + if ($this->verifyUserPass($username, $password) == "valid") |
|
525 | 525 | return $username.$password; |
526 | 526 | return $username; |
527 | 527 | } |
@@ -51,10 +51,10 @@ |
||
51 | 51 | 'WSCourse.DeleteCourse', |
52 | 52 | array('secret_key' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string'), |
53 | 53 | array(), |
54 | - 'urn:WSService', // namespace |
|
55 | - 'urn:WSService#WSCourse.DeleteCourse', // soapaction |
|
56 | - 'rpc', // style |
|
57 | - 'encoded', // use |
|
54 | + 'urn:WSService', // namespace |
|
55 | + 'urn:WSService#WSCourse.DeleteCourse', // soapaction |
|
56 | + 'rpc', // style |
|
57 | + 'encoded', // use |
|
58 | 58 | 'Delete a course in chamilo' // documentation |
59 | 59 | |
60 | 60 | ); |