@@ -11,18 +11,18 @@ discard block |
||
11 | 11 | api_protect_course_script(true); |
12 | 12 | |
13 | 13 | // display actions menu |
14 | -if (api_is_allowed_to_edit(null,true)) { |
|
14 | +if (api_is_allowed_to_edit(null, true)) { |
|
15 | 15 | $categories = array(); |
16 | 16 | foreach ($default_description_titles as $id => $title) { |
17 | 17 | $categories[$id] = $title; |
18 | 18 | } |
19 | 19 | $categories[ADD_BLOCK] = get_lang('NewBloc'); |
20 | 20 | |
21 | - $i=1; |
|
21 | + $i = 1; |
|
22 | 22 | echo '<div class="actions" style="margin-bottom:30px">'; |
23 | 23 | ksort($categories); |
24 | 24 | foreach ($categories as $id => $title) { |
25 | - if ($i==ADD_BLOCK) { |
|
25 | + if ($i == ADD_BLOCK) { |
|
26 | 26 | echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
27 | 27 | Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>'; |
28 | 28 | break; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | <tr> |
44 | 44 | <td><h3>'.get_lang('ThematicAdvanceHistory').'</h3></td> |
45 | 45 | <td align="right"><a href="index.php?action=listing">'. |
46 | - Display::return_icon('info.png',get_lang('BackToCourseDesriptionList'), array('style'=>'vertical-align:middle;'),ICON_SIZE_SMALL).' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>'; |
|
46 | + Display::return_icon('info.png', get_lang('BackToCourseDesriptionList'), array('style'=>'vertical-align:middle;'), ICON_SIZE_SMALL).' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $user_info = api_get_user_info(); |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | foreach ($descriptions as $id => $description) { |
53 | 53 | if (!empty($description)) { |
54 | 54 | $actions = ''; |
55 | - if (api_is_allowed_to_edit(null,true) && !$history) { |
|
55 | + if (api_is_allowed_to_edit(null, true) && !$history) { |
|
56 | 56 | if (api_get_session_id() == $description['session_id']) { |
57 | 57 | $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']); |
58 | 58 | |
59 | 59 | // delete |
60 | - $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&'.api_get_cidreq_params(api_get_course_id(), $description['session_id']).'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding())).'\')) return false;">'; |
|
61 | - $actions .= Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL); |
|
60 | + $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&'.api_get_cidreq_params(api_get_course_id(), $description['session_id']).'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding())).'\')) return false;">'; |
|
61 | + $actions .= Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'), ICON_SIZE_SMALL); |
|
62 | 62 | $actions .= '</a> '; |
63 | 63 | |
64 | 64 | // edit |
65 | 65 | $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&'.api_get_cidreq_params(api_get_course_id(), $description['session_id']).'&action=edit&description_type='.$description['description_type'].'">'; |
66 | - $actions .= Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),ICON_SIZE_SMALL); |
|
66 | + $actions .= Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'), ICON_SIZE_SMALL); |
|
67 | 67 | $actions .= '</a> '; |
68 | 68 | } else { |
69 | - $actions .= Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL); |
|
69 | + $actions .= Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'), ICON_SIZE_SMALL); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | echo Display::panel( |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | } |
35 | 35 | $categories[ADD_BLOCK] = get_lang('NewBloc'); |
36 | 36 | |
37 | -$i=1; |
|
37 | +$i = 1; |
|
38 | 38 | echo '<div class="actions" style="margin-bottom:30px">'; |
39 | 39 | echo '<a href="index.php?'.api_get_cidreq().'">'. |
40 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
40 | + Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM). |
|
41 | 41 | '</a>'; |
42 | 42 | |
43 | 43 | ksort($categories); |
44 | 44 | foreach ($categories as $id => $title) { |
45 | - if ($i==ADD_BLOCK) { |
|
45 | + if ($i == ADD_BLOCK) { |
|
46 | 46 | echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
47 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
47 | + Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>'; |
|
48 | 48 | break; |
49 | 49 | } else { |
50 | 50 | echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
51 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
51 | + Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>'; |
|
52 | 52 | $i++; |
53 | 53 | } |
54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | // error messages |
58 | 58 | if (isset($error) && intval($error) == 1) { |
59 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false); |
|
59 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // default header title form |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param string tool name (optional) |
17 | 17 | * @param string $template_path |
18 | 18 | */ |
19 | - public function __construct($toolname = '', $template_path=null) |
|
19 | + public function __construct($toolname = '', $template_path = null) |
|
20 | 20 | { |
21 | 21 | if (!empty($toolname)) { |
22 | 22 | if (isset($template_path)) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | if (is_dir($path)) { |
28 | 28 | $this->tool_path = $path; |
29 | 29 | } else { |
30 | - throw new Exception('View::__construct() $path directory does not exist ' . $path); |
|
30 | + throw new Exception('View::__construct() $path directory does not exist '.$path); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function set_data($data) |
40 | 40 | { |
41 | 41 | if (!is_array($data)) { |
42 | - throw new Exception('View::set_data() $data must to be an array, you have sent a' . gettype( $data )); |
|
42 | + throw new Exception('View::set_data() $data must to be an array, you have sent a'.gettype($data)); |
|
43 | 43 | } |
44 | 44 | $this->data = $data; |
45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string layout view |
50 | 50 | * @param string $layout |
51 | 51 | */ |
52 | - public function set_layout( $layout ) |
|
52 | + public function set_layout($layout) |
|
53 | 53 | { |
54 | 54 | $this->layout = $layout; |
55 | 55 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | // actions menu |
11 | 11 | $new_thematic_plan_data = array(); |
12 | 12 | if (!empty($thematic_plan_data)) |
13 | -foreach($thematic_plan_data as $thematic_item) { |
|
13 | +foreach ($thematic_plan_data as $thematic_item) { |
|
14 | 14 | $thematic_simple_list[] = $thematic_item['description_type']; |
15 | 15 | $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item; |
16 | 16 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | -$i=1; |
|
28 | +$i = 1; |
|
29 | 29 | |
30 | 30 | echo Display::tag('h2', $thematic_data['title']); |
31 | 31 | echo $thematic_data['content']; |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | $thematic_plan = null; |
68 | 68 | } else { |
69 | 69 | $thematic_plan = null; |
70 | - $default['title['.$id.']'] = $title; |
|
71 | - $default['description['.$id.']']= ''; |
|
70 | + $default['title['.$id.']'] = $title; |
|
71 | + $default['description['.$id.']'] = ''; |
|
72 | 72 | } |
73 | 73 | $form->setDefaults($default); |
74 | 74 | } |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | ]; |
18 | 18 | |
19 | 19 | foreach ($externalCSS as $css) { |
20 | - $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH) . $css); |
|
20 | + $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH).$css); |
|
21 | 21 | } |
22 | 22 | |
23 | -$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'chat.css'); |
|
24 | -$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH) . 'markdown.css'); |
|
23 | +$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css'); |
|
24 | +$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'markdown.css'); |
|
25 | 25 | |
26 | 26 | $externalJS = [ |
27 | 27 | 'highlight/highlight.pack.js', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | |
44 | - $iconList[$key] = strtoupper($icon) . '.png'; |
|
44 | + $iconList[$key] = strtoupper($icon).'.png'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $view = new Template(get_lang('Chat'), false, false, false, true, false); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | foreach ($sub_options as $sub_option) { |
218 | 218 | if (!empty($sub_option)) { |
219 | - $new_params = array( |
|
219 | + $new_params = array( |
|
220 | 220 | 'field_id' => $field_id, |
221 | 221 | 'option_value' => $sub_id, |
222 | 222 | 'display_text' => $sub_option, |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $form->addElement('hidden', 'field_id', $this->field_id); |
661 | 661 | |
662 | 662 | if ($action == 'edit') { |
663 | - $translateUrl = api_get_path(WEB_CODE_PATH) . 'extrafield/translate.php?' . http_build_query([ |
|
663 | + $translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'.http_build_query([ |
|
664 | 664 | 'extra_field_option' => $id |
665 | 665 | ]); |
666 | 666 | $translateButton = Display::toolbarButton(get_lang('TranslateThisTerm'), $translateUrl, 'language', 'link'); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // Now that there is an association created, move on |
65 | 65 | // to request authentication from the IdP |
66 | 66 | $identity = (!empty($services[0]['delegate'])) ? $services[0]['delegate'] : $claimed_id; |
67 | - if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 . '/server', $services[0]['types'])) { |
|
67 | + if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0.'/server', $services[0]['types'])) { |
|
68 | 68 | $identity = 'http://openid.net/identifier_select/2.0'; |
69 | 69 | } |
70 | 70 | $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | $xrds_url = $claimed_id; |
121 | 121 | if (_openid_is_xri($claimed_id)) { |
122 | - $xrds_url = 'http://xri.net/' . $claimed_id; |
|
122 | + $xrds_url = 'http://xri.net/'.$claimed_id; |
|
123 | 123 | } |
124 | 124 | $url = @parse_url($xrds_url); |
125 | 125 | if ($url['scheme'] == 'http' || $url['scheme'] == 'https') { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | //@todo Remove Old Associations: |
183 | 183 | $openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION); |
184 | 184 | $sql = "DELETE FROM $openid_association |
185 | - WHERE created + expires_in < '" . api_get_utc_datetime() . "'"; |
|
185 | + WHERE created + expires_in < '".api_get_utc_datetime()."'"; |
|
186 | 186 | Database::query($sql); |
187 | 187 | |
188 | 188 | // Check to see if we have an association for this IdP already |
@@ -339,17 +339,17 @@ discard block |
||
339 | 339 | switch ($uri['scheme']) { |
340 | 340 | case 'http': |
341 | 341 | $port = isset($uri['port']) ? $uri['port'] : 80; |
342 | - $host = $uri['host'] . ($port != 80 ? ':' . $port : ''); |
|
342 | + $host = $uri['host'].($port != 80 ? ':'.$port : ''); |
|
343 | 343 | $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); |
344 | 344 | break; |
345 | 345 | case 'https': |
346 | 346 | // Note: Only works for PHP 4.3 compiled with OpenSSL. |
347 | 347 | $port = isset($uri['port']) ? $uri['port'] : 443; |
348 | - $host = $uri['host'] . ($port != 443 ? ':' . $port : ''); |
|
349 | - $fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20); |
|
348 | + $host = $uri['host'].($port != 443 ? ':'.$port : ''); |
|
349 | + $fp = @fsockopen('ssl://'.$uri['host'], $port, $errno, $errstr, 20); |
|
350 | 350 | break; |
351 | 351 | default: |
352 | - $result->error = 'invalid schema ' . $uri['scheme']; |
|
352 | + $result->error = 'invalid schema '.$uri['scheme']; |
|
353 | 353 | return $result; |
354 | 354 | } |
355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | // Construct the path to act on. |
366 | 366 | $path = isset($uri['path']) ? $uri['path'] : '/'; |
367 | 367 | if (isset($uri['query'])) { |
368 | - $path .= '?' . $uri['query']; |
|
368 | + $path .= '?'.$uri['query']; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | // Create HTTP request. |
@@ -375,23 +375,23 @@ discard block |
||
375 | 375 | // host that do not take into account the port number. |
376 | 376 | 'Host' => "Host: $host", |
377 | 377 | 'User-Agent' => 'User-Agent: Chamilo (+http://www.chamilo.org/)', |
378 | - 'Content-Length' => 'Content-Length: ' . strlen($data) |
|
378 | + 'Content-Length' => 'Content-Length: '.strlen($data) |
|
379 | 379 | ); |
380 | 380 | |
381 | 381 | // If the server url has a user then attempt to use basic authentication |
382 | 382 | if (isset($uri['user'])) { |
383 | - $defaults['Authorization'] = 'Authorization: Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : '')); |
|
383 | + $defaults['Authorization'] = 'Authorization: Basic '.base64_encode($uri['user'].(!empty($uri['pass']) ? ":".$uri['pass'] : '')); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | foreach ($headers as $header => $value) { |
387 | - $defaults[$header] = $header . ': ' . $value; |
|
387 | + $defaults[$header] = $header.': '.$value; |
|
388 | 388 | } |
389 | 389 | |
390 | - $request = $method . ' ' . $path . " HTTP/1.0\r\n"; |
|
390 | + $request = $method.' '.$path." HTTP/1.0\r\n"; |
|
391 | 391 | $request .= implode("\r\n", $defaults); |
392 | 392 | $request .= "\r\n\r\n"; |
393 | 393 | if ($data) { |
394 | - $request .= $data . "\r\n"; |
|
394 | + $request .= $data."\r\n"; |
|
395 | 395 | } |
396 | 396 | $result->request = $request; |
397 | 397 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | if (isset($result->headers[$header]) && $header == 'Set-Cookie') { |
418 | 418 | // RFC 2109: the Set-Cookie response header comprises the token Set- |
419 | 419 | // Cookie:, followed by a comma-separated list of one or more cookies. |
420 | - $result->headers[$header] .= ',' . trim($value); |
|
420 | + $result->headers[$header] .= ','.trim($value); |
|
421 | 421 | } else { |
422 | 422 | $result->headers[$header] = trim($value); |
423 | 423 | } |
@@ -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(!empty($title)) { |
|
214 | + if (!empty($title)) { |
|
215 | 215 | $attributes['title'] = $title; |
216 | 216 | } |
217 | - if(!empty($category_code)) { |
|
217 | + if (!empty($category_code)) { |
|
218 | 218 | $attributes['category_code'] = $category_code; |
219 | 219 | } |
220 | - if(!empty($department_name)) { |
|
220 | + if (!empty($department_name)) { |
|
221 | 221 | $attributes['department_name'] = $department_name; |
222 | 222 | } |
223 | - if(!empty($department_url)) { |
|
223 | + if (!empty($department_url)) { |
|
224 | 224 | $attributes['department_url'] = $department_url; |
225 | 225 | } |
226 | - if(!empty($language)) { |
|
226 | + if (!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(!empty($visual_code)) { |
|
238 | + if (!empty($visual_code)) { |
|
239 | 239 | $attributes['visual_code'] = $visual_code; |
240 | 240 | } |
241 | - if(!empty($attributes)) { |
|
241 | + if (!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 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | protected function deleteCourseHelper($course_id_field_name, $course_id_value) { |
23 | 23 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
24 | - if($course_id instanceof WSError) { |
|
24 | + if ($course_id instanceof WSError) { |
|
25 | 25 | return $course_id; |
26 | 26 | } else { |
27 | 27 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) { |
41 | 41 | $verifKey = $this->verifyKey($secret_key); |
42 | - if($verifKey instanceof WSError) { |
|
42 | + if ($verifKey instanceof WSError) { |
|
43 | 43 | $this->handleError($verifKey); |
44 | 44 | } else { |
45 | 45 | $result = $this->deleteCourseHelper($course_id_field_name, $course_id_value); |
46 | - if($result instanceof WSError) { |
|
46 | + if ($result instanceof WSError) { |
|
47 | 47 | $this->handleError($result); |
48 | 48 | } |
49 | 49 | } |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function DeleteCourses($secret_key, $courses) { |
61 | 61 | $verifKey = $this->verifyKey($secret_key); |
62 | - if($verifKey instanceof WSError) { |
|
62 | + if ($verifKey instanceof WSError) { |
|
63 | 63 | $this->handleError($verifKey); |
64 | 64 | } else { |
65 | 65 | $results = array(); |
66 | - foreach($courses as $course) { |
|
66 | + foreach ($courses as $course) { |
|
67 | 67 | $result_tmp = array(); |
68 | 68 | $result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']); |
69 | 69 | $result_tmp['course_id_value'] = $course['course_id_value']; |
70 | - if($result_op instanceof WSError) { |
|
70 | + if ($result_op instanceof WSError) { |
|
71 | 71 | // Return the error in the results |
72 | 72 | $result_tmp['result'] = $result_op->toArray(); |
73 | 73 | } else { |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | 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) { |
98 | 98 | // Add the original course id field name and value to the extra fields if needed |
99 | 99 | $extras_associative = array(); |
100 | - if($course_id_field_name != "chamilo_course_id") { |
|
100 | + if ($course_id_field_name != "chamilo_course_id") { |
|
101 | 101 | $extras_associative[$course_id_field_name] = $course_id_value; |
102 | 102 | } |
103 | - foreach($extras as $extra) { |
|
103 | + foreach ($extras as $extra) { |
|
104 | 104 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
105 | 105 | } |
106 | 106 | $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
107 | - if($course_admin_id instanceof WSError) { |
|
107 | + if ($course_admin_id instanceof WSError) { |
|
108 | 108 | return $course_admin_id; |
109 | 109 | } |
110 | - if($wanted_code == '') { |
|
110 | + if ($wanted_code == '') { |
|
111 | 111 | $wanted_code = CourseManager::generate_course_code($title); |
112 | 112 | } |
113 | 113 | $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return new WSError(202, 'There was an error creating the course'); |
116 | 116 | } else { |
117 | 117 | // Update extra fields |
118 | - foreach($extras_associative as $fname => $fvalue) { |
|
118 | + foreach ($extras_associative as $fname => $fvalue) { |
|
119 | 119 | CourseManager::update_course_extra_field_value($result, $fname, $fvalue); |
120 | 120 | } |
121 | 121 | // Get course id |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | 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) { |
144 | 144 | // First, verify the secret key |
145 | 145 | $verifKey = $this->verifyKey($secret_key); |
146 | - if($verifKey instanceof WSError) { |
|
146 | + if ($verifKey instanceof WSError) { |
|
147 | 147 | $this->handleError($verifKey); |
148 | 148 | } else { |
149 | 149 | $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); |
150 | - if($result instanceof WSError) { |
|
150 | + if ($result instanceof WSError) { |
|
151 | 151 | $this->handleError($result); |
152 | 152 | } else { |
153 | 153 | return $result; |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | public function CreateCourses($secret_key, $courses) { |
166 | 166 | // First, verify the secret key |
167 | 167 | $verifKey = $this->verifyKey($secret_key); |
168 | - if($verifKey instanceof WSError) { |
|
168 | + if ($verifKey instanceof WSError) { |
|
169 | 169 | $this->handleError($verifKey); |
170 | 170 | } else { |
171 | 171 | $results = array(); |
172 | - foreach($courses as $course) { |
|
172 | + foreach ($courses as $course) { |
|
173 | 173 | $result_tmp = array(); |
174 | 174 | // re-initialize variables just in case |
175 | 175 | $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 = 0; |
176 | 176 | extract($course); |
177 | 177 | $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); |
178 | - if($result instanceof WSError) { |
|
178 | + if ($result instanceof WSError) { |
|
179 | 179 | $result_tmp['result'] = $result->toArray(); |
180 | 180 | $result_tmp['course_id_value'] = $course_id_value; |
181 | 181 | $result_tmp['course_id_generated'] = 0; |
@@ -209,47 +209,47 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) { |
211 | 211 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
212 | - if($course_id instanceof WSError) { |
|
212 | + if ($course_id instanceof WSError) { |
|
213 | 213 | return $course_id; |
214 | 214 | } else { |
215 | 215 | $attributes = array(); |
216 | - if(!empty($title)) { |
|
216 | + if (!empty($title)) { |
|
217 | 217 | $attributes['title'] = $title; |
218 | 218 | } |
219 | - if(!empty($category_code)) { |
|
219 | + if (!empty($category_code)) { |
|
220 | 220 | $attributes['category_code'] = $category_code; |
221 | 221 | } |
222 | - if(!empty($department_name)) { |
|
222 | + if (!empty($department_name)) { |
|
223 | 223 | $attributes['department_name'] = $department_name; |
224 | 224 | } |
225 | - if(!empty($department_url)) { |
|
225 | + if (!empty($department_url)) { |
|
226 | 226 | $attributes['department_url'] = $department_url; |
227 | 227 | } |
228 | - if(!empty($language)) { |
|
228 | + if (!empty($language)) { |
|
229 | 229 | $attributes['course_language'] = $language; |
230 | 230 | } |
231 | - if($visibility != '') { |
|
232 | - $attributes['visibility'] = (int)$visibility; |
|
231 | + if ($visibility != '') { |
|
232 | + $attributes['visibility'] = (int) $visibility; |
|
233 | 233 | } |
234 | - if($subscribe != '') { |
|
235 | - $attributes['subscribe'] = (int)$subscribe; |
|
234 | + if ($subscribe != '') { |
|
235 | + $attributes['subscribe'] = (int) $subscribe; |
|
236 | 236 | } |
237 | - if($unsubscribe != '') { |
|
238 | - $attributes['unsubscribe'] = (int)$unsubscribe; |
|
237 | + if ($unsubscribe != '') { |
|
238 | + $attributes['unsubscribe'] = (int) $unsubscribe; |
|
239 | 239 | } |
240 | - if(!empty($visual_code)) { |
|
240 | + if (!empty($visual_code)) { |
|
241 | 241 | $attributes['visual_code'] = $visual_code; |
242 | 242 | } |
243 | - if(!empty($attributes)) { |
|
243 | + if (!empty($attributes)) { |
|
244 | 244 | CourseManager::update_attributes($course_id, $attributes); |
245 | 245 | } |
246 | - if(!empty($extras)) { |
|
246 | + if (!empty($extras)) { |
|
247 | 247 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
248 | 248 | $extras_associative = array(); |
249 | - foreach($extras as $extra) { |
|
249 | + foreach ($extras as $extra) { |
|
250 | 250 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
251 | 251 | } |
252 | - foreach($extras_associative as $fname => $fvalue) { |
|
252 | + foreach ($extras_associative as $fname => $fvalue) { |
|
253 | 253 | CourseManager::update_extra_field_value($course_code, $fname, $fvalue); |
254 | 254 | } |
255 | 255 | } |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | 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) { |
278 | 278 | $verifKey = $this->verifyKey($secret_key); |
279 | - if($verifKey instanceof WSError) { |
|
279 | + if ($verifKey instanceof WSError) { |
|
280 | 280 | $this->handleError($verifKey); |
281 | 281 | } else { |
282 | 282 | $result = $this->editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras); |
283 | - if($result instanceof WSError) { |
|
283 | + if ($result instanceof WSError) { |
|
284 | 284 | $this->handleError($result); |
285 | 285 | } |
286 | 286 | } |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') { |
298 | 298 | $verifKey = $this->verifyKey($secret_key); |
299 | - if($verifKey instanceof WSError) { |
|
299 | + if ($verifKey instanceof WSError) { |
|
300 | 300 | $this->handleError($verifKey); |
301 | 301 | } else { |
302 | - $visibilities = split(',',$visibility); |
|
302 | + $visibilities = split(',', $visibility); |
|
303 | 303 | $vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0'); |
304 | 304 | foreach ($visibilities as $p => $visibility) { |
305 | 305 | $visibilities[$p] = $vis[$visibility]; |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | $category_names = array(); |
309 | 309 | |
310 | 310 | $courses = CourseManager::get_courses_list(); |
311 | - foreach($courses as $course) { |
|
311 | + foreach ($courses as $course) { |
|
312 | 312 | //skip elements that do not match required visibility |
313 | - if (!in_array($course['visibility'],$visibilities)) { continue; } |
|
313 | + if (!in_array($course['visibility'], $visibilities)) { continue; } |
|
314 | 314 | $course_tmp = array(); |
315 | 315 | $course_tmp['id'] = $course['id']; |
316 | 316 | $course_tmp['code'] = $course['code']; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $course_tmp['visibility'] = $course['visibility']; |
320 | 320 | |
321 | 321 | // Determining category name |
322 | - if($category_names[$course['category_code']]) { |
|
322 | + if ($category_names[$course['category_code']]) { |
|
323 | 323 | $course_tmp['category_name'] = $category_names[$course['category_code']]; |
324 | 324 | } else { |
325 | 325 | $category = CourseManager::get_course_category($course['category_code']); |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | */ |
356 | 356 | protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) { |
357 | 357 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
358 | - if($course_id instanceof WSError) { |
|
358 | + if ($course_id instanceof WSError) { |
|
359 | 359 | return $course_id; |
360 | 360 | } else { |
361 | 361 | $user_id = $this->getUserId($user_id_field_name, $user_id_value); |
362 | - if($user_id instanceof WSError) { |
|
362 | + if ($user_id instanceof WSError) { |
|
363 | 363 | return $user_id; |
364 | 364 | } else { |
365 | 365 | $course_code = CourseManager::get_course_code_from_course_id($course_id); |
366 | - if($state == 0) { |
|
366 | + if ($state == 0) { |
|
367 | 367 | // Unsubscribe user |
368 | 368 | CourseManager::unsubscribe_user($user_id, $course_code); |
369 | 369 | return true; |
370 | 370 | } else { |
371 | 371 | // Subscribe user |
372 | - if(CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
372 | + if (CourseManager::subscribe_user($user_id, $course_code, $status)) { |
|
373 | 373 | return true; |
374 | 374 | } else { |
375 | 375 | return new WSError(203, 'An error occured subscribing to this course'); |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) { |
393 | 393 | $verifKey = $this->verifyKey($secret_key); |
394 | - if($verifKey instanceof WSError) { |
|
394 | + if ($verifKey instanceof WSError) { |
|
395 | 395 | $this->handleError($verifKey); |
396 | 396 | } else { |
397 | 397 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status); |
398 | - if($result instanceof WSError) { |
|
398 | + if ($result instanceof WSError) { |
|
399 | 399 | $this->handleError($result); |
400 | 400 | } |
401 | 401 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) { |
414 | 414 | $verifKey = $this->verifyKey($secret_key); |
415 | - if($verifKey instanceof WSError) { |
|
415 | + if ($verifKey instanceof WSError) { |
|
416 | 416 | $this->handleError($verifKey); |
417 | 417 | } else { |
418 | 418 | $result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0); |
419 | - if($result instanceof WSError) { |
|
419 | + if ($result instanceof WSError) { |
|
420 | 420 | $this->handleError($result); |
421 | 421 | } |
422 | 422 | } |
@@ -432,17 +432,17 @@ discard block |
||
432 | 432 | */ |
433 | 433 | public function GetCourseDescriptions($secret_key, $course_id_field_name, $course_id_value) { |
434 | 434 | $verifKey = $this->verifyKey($secret_key); |
435 | - if($verifKey instanceof WSError) { |
|
435 | + if ($verifKey instanceof WSError) { |
|
436 | 436 | $this->handleError($verifKey); |
437 | 437 | } else { |
438 | 438 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
439 | - if($course_id instanceof WSError) { |
|
439 | + if ($course_id instanceof WSError) { |
|
440 | 440 | return $course_id; |
441 | 441 | } else { |
442 | 442 | // Course exists, get its descriptions |
443 | 443 | $descriptions = CourseDescription::get_descriptions($course_id); |
444 | 444 | $results = array(); |
445 | - foreach($descriptions as $description) { |
|
445 | + foreach ($descriptions as $description) { |
|
446 | 446 | $results[] = array('course_desc_id' => $description->get_description_type(), |
447 | 447 | 'course_desc_title' => $description->get_title(), |
448 | 448 | 'course_desc_content' => $description->get_content()); |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
467 | 467 | $verifKey = $this->verifyKey($secret_key); |
468 | - if($verifKey instanceof WSError) { |
|
468 | + if ($verifKey instanceof WSError) { |
|
469 | 469 | $this->handleError($verifKey); |
470 | 470 | } else { |
471 | 471 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
472 | - if($course_id instanceof WSError) { |
|
472 | + if ($course_id instanceof WSError) { |
|
473 | 473 | return $course_id; |
474 | 474 | } else { |
475 | 475 | // Create the new course description |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | // Check if this course description exists |
485 | 485 | $descriptions = CourseDescription::get_descriptions($course_id); |
486 | 486 | $exists = false; |
487 | - foreach($descriptions as $description) { |
|
488 | - if($description->get_description_type() == $course_desc_id) { |
|
487 | + foreach ($descriptions as $description) { |
|
488 | + if ($description->get_description_type() == $course_desc_id) { |
|
489 | 489 | $exists = true; |
490 | 490 | } |
491 | 491 | } |