@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
35 | 35 | |
36 | 36 | if (count($array_to_search) > 0) { |
37 | - while (list($key) = each($array_to_search)) { |
|
38 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | - } |
|
37 | + while (list($key) = each($array_to_search)) { |
|
38 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //get all svg and png group files |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1 |
71 | 71 | ){ |
72 | 72 | |
73 | - if (!empty($png_svg_files)) { |
|
74 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | - echo '<ul>'; |
|
76 | - foreach($png_svg_files as $filename) { |
|
77 | - $image = $group_disk_path.$filename; |
|
78 | - |
|
79 | - if (strpos($filename, "svg")){ |
|
80 | - $new_sizes['width'] = 60; |
|
81 | - $new_sizes['height'] = 60; |
|
82 | - } else { |
|
83 | - $new_sizes = api_resize_image($image, 60, 60); |
|
84 | - } |
|
73 | + if (!empty($png_svg_files)) { |
|
74 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | + echo '<ul>'; |
|
76 | + foreach($png_svg_files as $filename) { |
|
77 | + $image = $group_disk_path.$filename; |
|
78 | + |
|
79 | + if (strpos($filename, "svg")){ |
|
80 | + $new_sizes['width'] = 60; |
|
81 | + $new_sizes['height'] = 60; |
|
82 | + } else { |
|
83 | + $new_sizes = api_resize_image($image, 60, 60); |
|
84 | + } |
|
85 | 85 | echo '<li style="display:inline; padding:8px;">'; |
86 | 86 | echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">'; |
87 | 87 | echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
88 | - } |
|
89 | - echo '</ul>'; |
|
90 | - } |
|
88 | + } |
|
89 | + echo '</ul>'; |
|
90 | + } |
|
91 | 91 | } else { |
92 | - echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
92 | + echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | </body> |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
24 | 24 | |
25 | 25 | if (count($array_to_search) > 0) { |
26 | - while (list($key) = each($array_to_search)) { |
|
27 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
28 | - } |
|
26 | + while (list($key) = each($array_to_search)) { |
|
27 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | //get all svg and png files |
32 | 32 | $accepted_extensions = array('.svg', '.png'); |
33 | 33 | |
34 | 34 | if (is_array($all_files) && count($all_files) > 0) { |
35 | - foreach ($all_files as & $file) { |
|
36 | - $slideshow_extension = strrchr($file, '.'); |
|
37 | - $slideshow_extension = strtolower($slideshow_extension); |
|
38 | - if (in_array($slideshow_extension, $accepted_extensions)) { |
|
39 | - $png_svg_files[] =$file; |
|
40 | - } |
|
41 | - } |
|
35 | + foreach ($all_files as & $file) { |
|
36 | + $slideshow_extension = strrchr($file, '.'); |
|
37 | + $slideshow_extension = strtolower($slideshow_extension); |
|
38 | + if (in_array($slideshow_extension, $accepted_extensions)) { |
|
39 | + $png_svg_files[] =$file; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | $disk_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images/gallery/'; |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | <?php |
58 | 58 | echo '<h2>'.get_lang('Course').': '.$course_info['name'].'</h2>'; |
59 | 59 | if (!empty($png_svg_files)) { |
60 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
61 | - echo '<ul>'; |
|
62 | - foreach($png_svg_files as $filename) { |
|
63 | - $image=$disk_path.$filename; |
|
64 | - |
|
65 | - if (strpos($filename, "svg")){ |
|
66 | - $new_sizes['width'] = 60; |
|
67 | - $new_sizes['height'] = 60; |
|
68 | - } |
|
69 | - else { |
|
70 | - $new_sizes = api_resize_image($image, 60, 60); |
|
71 | - } |
|
72 | - |
|
73 | - echo '<li style="display:inline; padding:8px;"><a href="'.$web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
74 | - } |
|
75 | - echo '</ul>'; |
|
60 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
61 | + echo '<ul>'; |
|
62 | + foreach($png_svg_files as $filename) { |
|
63 | + $image=$disk_path.$filename; |
|
64 | + |
|
65 | + if (strpos($filename, "svg")){ |
|
66 | + $new_sizes['width'] = 60; |
|
67 | + $new_sizes['height'] = 60; |
|
68 | + } |
|
69 | + else { |
|
70 | + $new_sizes = api_resize_image($image, 60, 60); |
|
71 | + } |
|
72 | + |
|
73 | + echo '<li style="display:inline; padding:8px;"><a href="'.$web_path.$filename.'" alt "'.$filename.'" title="'.$filename.'"><img src="'.$web_path.$filename.'" width="'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
|
74 | + } |
|
75 | + echo '</ul>'; |
|
76 | 76 | } else { |
77 | - Display::display_warning_message(get_lang('NoSVGImagesInImagesGalleryPath')); |
|
77 | + Display::display_warning_message(get_lang('NoSVGImagesInImagesGalleryPath')); |
|
78 | 78 | } |
79 | 79 | ?> |
80 | 80 | </body> |
@@ -46,59 +46,59 @@ discard block |
||
46 | 46 | // Please, do not modify this dirname formatting |
47 | 47 | |
48 | 48 | if (strstr($dir, '..')) { |
49 | - $dir = '/'; |
|
49 | + $dir = '/'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if ($dir[0] == '.') { |
53 | - $dir = substr($dir, 1); |
|
53 | + $dir = substr($dir, 1); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($dir[0] != '/') { |
57 | - $dir = '/'.$dir; |
|
57 | + $dir = '/'.$dir; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($dir[strlen($dir) - 1] != '/') { |
61 | - $dir .= '/'; |
|
61 | + $dir .= '/'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
65 | 65 | |
66 | 66 | if (!is_dir($filepath)) { |
67 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
68 | - $dir = '/'; |
|
67 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
68 | + $dir = '/'; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $groupId = api_get_group_id(); |
72 | 72 | |
73 | 73 | if (!empty($groupId)) { |
74 | - $interbreadcrumb[] = array ( |
|
74 | + $interbreadcrumb[] = array ( |
|
75 | 75 | "url" => "../group/group_space.php?".api_get_cidreq(), |
76 | 76 | "name" => get_lang('GroupSpace') |
77 | 77 | ); |
78 | - $noPHP_SELF = true; |
|
79 | - $group = GroupManager :: get_group_properties($groupId); |
|
80 | - $path = explode('/', $dir); |
|
81 | - if ('/'.$path[1] != $group['directory']) { |
|
82 | - api_not_allowed(true); |
|
83 | - } |
|
78 | + $noPHP_SELF = true; |
|
79 | + $group = GroupManager :: get_group_properties($groupId); |
|
80 | + $path = explode('/', $dir); |
|
81 | + if ('/'.$path[1] != $group['directory']) { |
|
82 | + api_not_allowed(true); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $interbreadcrumb[] = array( |
87 | - "url" => "./document.php?".api_get_cidreq(), |
|
88 | - "name" => get_lang('Documents') |
|
87 | + "url" => "./document.php?".api_get_cidreq(), |
|
88 | + "name" => get_lang('Documents') |
|
89 | 89 | ); |
90 | 90 | |
91 | 91 | if (!$is_allowed_in_course) { |
92 | - api_not_allowed(true); |
|
92 | + api_not_allowed(true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || |
96 | - DocumentManager::is_my_shared_folder( |
|
97 | - api_get_user_id(), |
|
98 | - Security::remove_XSS($dir), |
|
99 | - api_get_session_id())) |
|
96 | + DocumentManager::is_my_shared_folder( |
|
97 | + api_get_user_id(), |
|
98 | + Security::remove_XSS($dir), |
|
99 | + api_get_session_id())) |
|
100 | 100 | ) { |
101 | - api_not_allowed(true); |
|
101 | + api_not_allowed(true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | Event::event_access_tool(TOOL_DOCUMENT); |
107 | 107 | $display_dir = $dir; |
108 | 108 | if (isset ($group)) { |
109 | - $display_dir = explode('/', $dir); |
|
110 | - unset ($display_dir[0]); |
|
111 | - unset ($display_dir[1]); |
|
112 | - $display_dir = implode('/', $display_dir); |
|
109 | + $display_dir = explode('/', $dir); |
|
110 | + unset ($display_dir[0]); |
|
111 | + unset ($display_dir[1]); |
|
112 | + $display_dir = implode('/', $display_dir); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Interbreadcrumb for the current directory root path |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | } else { |
124 | 124 | foreach ($document_data['parents'] as $document_sub_data) { |
125 | 125 | $interbreadcrumb[] = array( |
126 | - 'url' => $document_sub_data['document_url'], |
|
127 | - 'name' => $document_sub_data['title'] |
|
128 | - ); |
|
126 | + 'url' => $document_sub_data['document_url'], |
|
127 | + 'name' => $document_sub_data['title'] |
|
128 | + ); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | Display :: display_header($nameTools, 'Doc'); |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | |
138 | 138 | if (api_browser_support('svg')) { |
139 | 139 | |
140 | - //automatic loading the course language |
|
141 | - $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
142 | - $langsvgedit = api_get_language_isocode(); |
|
143 | - $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
144 | - $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
145 | - $svg_url= api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?lang='.$langsvgedit; |
|
146 | - ?> |
|
140 | + //automatic loading the course language |
|
141 | + $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
142 | + $langsvgedit = api_get_language_isocode(); |
|
143 | + $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
144 | + $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
145 | + $svg_url= api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?lang='.$langsvgedit; |
|
146 | + ?> |
|
147 | 147 | <script> |
148 | 148 | document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'); |
149 | 149 | function resizeIframe() { |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | |
162 | 162 | <?php |
163 | 163 | echo '<noscript>'; |
164 | - echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
165 | - echo '</noscript>'; |
|
164 | + echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
165 | + echo '</noscript>'; |
|
166 | 166 | } else { |
167 | - Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
167 | + Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | Display :: display_footer(); |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |
@@ -33,99 +33,99 @@ discard block |
||
33 | 33 | class SignedRequest |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - public $rawSignedRequest; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - public $payload; |
|
45 | - |
|
46 | - /** |
|
47 | - * Instantiate a new SignedRequest entity. |
|
48 | - * |
|
49 | - * @param string|null $rawSignedRequest The raw signed request. |
|
50 | - * @param string|null $state random string to prevent CSRF. |
|
51 | - * @param string|null $appSecret |
|
52 | - */ |
|
53 | - public function __construct($rawSignedRequest = null, $state = null, $appSecret = null) |
|
54 | - { |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + public $rawSignedRequest; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + public $payload; |
|
45 | + |
|
46 | + /** |
|
47 | + * Instantiate a new SignedRequest entity. |
|
48 | + * |
|
49 | + * @param string|null $rawSignedRequest The raw signed request. |
|
50 | + * @param string|null $state random string to prevent CSRF. |
|
51 | + * @param string|null $appSecret |
|
52 | + */ |
|
53 | + public function __construct($rawSignedRequest = null, $state = null, $appSecret = null) |
|
54 | + { |
|
55 | 55 | if (!$rawSignedRequest) { |
56 | - return; |
|
56 | + return; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $this->rawSignedRequest = $rawSignedRequest; |
60 | 60 | $this->payload = static::parse($rawSignedRequest, $state, $appSecret); |
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns the raw signed request data. |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getRawSignedRequest() |
|
69 | - { |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns the raw signed request data. |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getRawSignedRequest() |
|
69 | + { |
|
70 | 70 | return $this->rawSignedRequest; |
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Returns the parsed signed request data. |
|
75 | - * |
|
76 | - * @return array|null |
|
77 | - */ |
|
78 | - public function getPayload() |
|
79 | - { |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Returns the parsed signed request data. |
|
75 | + * |
|
76 | + * @return array|null |
|
77 | + */ |
|
78 | + public function getPayload() |
|
79 | + { |
|
80 | 80 | return $this->payload; |
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Returns a property from the signed request data if available. |
|
85 | - * |
|
86 | - * @param string $key |
|
87 | - * @param integer $default |
|
88 | - * |
|
89 | - * @return mixed|null |
|
90 | - */ |
|
91 | - public function get($key, $default = null) |
|
92 | - { |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Returns a property from the signed request data if available. |
|
85 | + * |
|
86 | + * @param string $key |
|
87 | + * @param integer $default |
|
88 | + * |
|
89 | + * @return mixed|null |
|
90 | + */ |
|
91 | + public function get($key, $default = null) |
|
92 | + { |
|
93 | 93 | if (isset($this->payload[$key])) { |
94 | - return $this->payload[$key]; |
|
94 | + return $this->payload[$key]; |
|
95 | 95 | } |
96 | 96 | return $default; |
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Returns user_id from signed request data if available. |
|
101 | - * |
|
102 | - * @return string|null |
|
103 | - */ |
|
104 | - public function getUserId() |
|
105 | - { |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Returns user_id from signed request data if available. |
|
101 | + * |
|
102 | + * @return string|null |
|
103 | + */ |
|
104 | + public function getUserId() |
|
105 | + { |
|
106 | 106 | return $this->get('user_id'); |
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Checks for OAuth data in the payload. |
|
111 | - * |
|
112 | - * @return boolean |
|
113 | - */ |
|
114 | - public function hasOAuthData() |
|
115 | - { |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Checks for OAuth data in the payload. |
|
111 | + * |
|
112 | + * @return boolean |
|
113 | + */ |
|
114 | + public function hasOAuthData() |
|
115 | + { |
|
116 | 116 | return isset($this->payload['oauth_token']) || isset($this->payload['code']); |
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Creates a signed request from an array of data. |
|
121 | - * |
|
122 | - * @param array $payload |
|
123 | - * @param string|null $appSecret |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public static function make(array $payload, $appSecret = null) |
|
128 | - { |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Creates a signed request from an array of data. |
|
121 | + * |
|
122 | + * @param array $payload |
|
123 | + * @param string|null $appSecret |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public static function make(array $payload, $appSecret = null) |
|
128 | + { |
|
129 | 129 | $payload['algorithm'] = 'HMAC-SHA256'; |
130 | 130 | $payload['issued_at'] = time(); |
131 | 131 | $encodedPayload = static::base64UrlEncode(json_encode($payload)); |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | $encodedSig = static::base64UrlEncode($hashedSig); |
135 | 135 | |
136 | 136 | return $encodedSig.'.'.$encodedPayload; |
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Validates and decodes a signed request and returns |
|
141 | - * the payload as an array. |
|
142 | - * |
|
143 | - * @param string $signedRequest |
|
144 | - * @param string|null $state |
|
145 | - * @param string|null $appSecret |
|
146 | - * |
|
147 | - * @return array |
|
148 | - */ |
|
149 | - public static function parse($signedRequest, $state = null, $appSecret = null) |
|
150 | - { |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Validates and decodes a signed request and returns |
|
141 | + * the payload as an array. |
|
142 | + * |
|
143 | + * @param string $signedRequest |
|
144 | + * @param string|null $state |
|
145 | + * @param string|null $appSecret |
|
146 | + * |
|
147 | + * @return array |
|
148 | + */ |
|
149 | + public static function parse($signedRequest, $state = null, $appSecret = null) |
|
150 | + { |
|
151 | 151 | list($encodedSig, $encodedPayload) = static::split($signedRequest); |
152 | 152 | |
153 | 153 | // Signature validation |
@@ -159,228 +159,228 @@ discard block |
||
159 | 159 | $data = static::decodePayload($encodedPayload); |
160 | 160 | static::validateAlgorithm($data); |
161 | 161 | if ($state) { |
162 | - static::validateCsrf($data, $state); |
|
162 | + static::validateCsrf($data, $state); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $data; |
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Validates the format of a signed request. |
|
170 | - * |
|
171 | - * @param string $signedRequest |
|
172 | - * |
|
173 | - * @throws FacebookSDKException |
|
174 | - */ |
|
175 | - public static function validateFormat($signedRequest) |
|
176 | - { |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Validates the format of a signed request. |
|
170 | + * |
|
171 | + * @param string $signedRequest |
|
172 | + * |
|
173 | + * @throws FacebookSDKException |
|
174 | + */ |
|
175 | + public static function validateFormat($signedRequest) |
|
176 | + { |
|
177 | 177 | if (strpos($signedRequest, '.') !== false) { |
178 | - return; |
|
178 | + return; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | throw new FacebookSDKException( |
182 | - 'Malformed signed request.', 606 |
|
182 | + 'Malformed signed request.', 606 |
|
183 | 183 | ); |
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Decodes a raw valid signed request. |
|
188 | - * |
|
189 | - * @param string $signedRequest |
|
190 | - * |
|
191 | - * @returns array |
|
192 | - */ |
|
193 | - public static function split($signedRequest) |
|
194 | - { |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Decodes a raw valid signed request. |
|
188 | + * |
|
189 | + * @param string $signedRequest |
|
190 | + * |
|
191 | + * @returns array |
|
192 | + */ |
|
193 | + public static function split($signedRequest) |
|
194 | + { |
|
195 | 195 | static::validateFormat($signedRequest); |
196 | 196 | |
197 | 197 | return explode('.', $signedRequest, 2); |
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Decodes the raw signature from a signed request. |
|
202 | - * |
|
203 | - * @param string $encodedSig |
|
204 | - * |
|
205 | - * @returns string |
|
206 | - * |
|
207 | - * @throws FacebookSDKException |
|
208 | - */ |
|
209 | - public static function decodeSignature($encodedSig) |
|
210 | - { |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Decodes the raw signature from a signed request. |
|
202 | + * |
|
203 | + * @param string $encodedSig |
|
204 | + * |
|
205 | + * @returns string |
|
206 | + * |
|
207 | + * @throws FacebookSDKException |
|
208 | + */ |
|
209 | + public static function decodeSignature($encodedSig) |
|
210 | + { |
|
211 | 211 | $sig = static::base64UrlDecode($encodedSig); |
212 | 212 | |
213 | 213 | if ($sig) { |
214 | - return $sig; |
|
214 | + return $sig; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | throw new FacebookSDKException( |
218 | - 'Signed request has malformed encoded signature data.', 607 |
|
218 | + 'Signed request has malformed encoded signature data.', 607 |
|
219 | 219 | ); |
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Decodes the raw payload from a signed request. |
|
224 | - * |
|
225 | - * @param string $encodedPayload |
|
226 | - * |
|
227 | - * @returns array |
|
228 | - * |
|
229 | - * @throws FacebookSDKException |
|
230 | - */ |
|
231 | - public static function decodePayload($encodedPayload) |
|
232 | - { |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Decodes the raw payload from a signed request. |
|
224 | + * |
|
225 | + * @param string $encodedPayload |
|
226 | + * |
|
227 | + * @returns array |
|
228 | + * |
|
229 | + * @throws FacebookSDKException |
|
230 | + */ |
|
231 | + public static function decodePayload($encodedPayload) |
|
232 | + { |
|
233 | 233 | $payload = static::base64UrlDecode($encodedPayload); |
234 | 234 | |
235 | 235 | if ($payload) { |
236 | - $payload = json_decode($payload, true); |
|
236 | + $payload = json_decode($payload, true); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | if (is_array($payload)) { |
240 | - return $payload; |
|
240 | + return $payload; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | throw new FacebookSDKException( |
244 | - 'Signed request has malformed encoded payload data.', 607 |
|
244 | + 'Signed request has malformed encoded payload data.', 607 |
|
245 | 245 | ); |
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Validates the algorithm used in a signed request. |
|
250 | - * |
|
251 | - * @param array $data |
|
252 | - * |
|
253 | - * @throws FacebookSDKException |
|
254 | - */ |
|
255 | - public static function validateAlgorithm(array $data) |
|
256 | - { |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * Validates the algorithm used in a signed request. |
|
250 | + * |
|
251 | + * @param array $data |
|
252 | + * |
|
253 | + * @throws FacebookSDKException |
|
254 | + */ |
|
255 | + public static function validateAlgorithm(array $data) |
|
256 | + { |
|
257 | 257 | if (isset($data['algorithm']) && $data['algorithm'] === 'HMAC-SHA256') { |
258 | - return; |
|
258 | + return; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | throw new FacebookSDKException( |
262 | - 'Signed request is using the wrong algorithm.', 605 |
|
262 | + 'Signed request is using the wrong algorithm.', 605 |
|
263 | 263 | ); |
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Hashes the signature used in a signed request. |
|
268 | - * |
|
269 | - * @param string $encodedData |
|
270 | - * @param string|null $appSecret |
|
271 | - * |
|
272 | - * @return string |
|
273 | - * |
|
274 | - * @throws FacebookSDKException |
|
275 | - */ |
|
276 | - public static function hashSignature($encodedData, $appSecret = null) |
|
277 | - { |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Hashes the signature used in a signed request. |
|
268 | + * |
|
269 | + * @param string $encodedData |
|
270 | + * @param string|null $appSecret |
|
271 | + * |
|
272 | + * @return string |
|
273 | + * |
|
274 | + * @throws FacebookSDKException |
|
275 | + */ |
|
276 | + public static function hashSignature($encodedData, $appSecret = null) |
|
277 | + { |
|
278 | 278 | $hashedSig = hash_hmac( |
279 | - 'sha256', $encodedData, FacebookSession::_getTargetAppSecret($appSecret), $raw_output = true |
|
279 | + 'sha256', $encodedData, FacebookSession::_getTargetAppSecret($appSecret), $raw_output = true |
|
280 | 280 | ); |
281 | 281 | |
282 | 282 | if ($hashedSig) { |
283 | - return $hashedSig; |
|
283 | + return $hashedSig; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | throw new FacebookSDKException( |
287 | - 'Unable to hash signature from encoded payload data.', 602 |
|
287 | + 'Unable to hash signature from encoded payload data.', 602 |
|
288 | 288 | ); |
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Validates the signature used in a signed request. |
|
293 | - * |
|
294 | - * @param string $hashedSig |
|
295 | - * @param string $sig |
|
296 | - * |
|
297 | - * @throws FacebookSDKException |
|
298 | - */ |
|
299 | - public static function validateSignature($hashedSig, $sig) |
|
300 | - { |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Validates the signature used in a signed request. |
|
293 | + * |
|
294 | + * @param string $hashedSig |
|
295 | + * @param string $sig |
|
296 | + * |
|
297 | + * @throws FacebookSDKException |
|
298 | + */ |
|
299 | + public static function validateSignature($hashedSig, $sig) |
|
300 | + { |
|
301 | 301 | if (mb_strlen($hashedSig) === mb_strlen($sig)) { |
302 | - $validate = 0; |
|
303 | - for ($i = 0; $i < mb_strlen($sig); $i++) { |
|
302 | + $validate = 0; |
|
303 | + for ($i = 0; $i < mb_strlen($sig); $i++) { |
|
304 | 304 | $validate |= ord($hashedSig[$i]) ^ ord($sig[$i]); |
305 | - } |
|
306 | - if ($validate === 0) { |
|
305 | + } |
|
306 | + if ($validate === 0) { |
|
307 | 307 | return; |
308 | - } |
|
308 | + } |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | throw new FacebookSDKException( |
312 | - 'Signed request has an invalid signature.', 602 |
|
312 | + 'Signed request has an invalid signature.', 602 |
|
313 | 313 | ); |
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Validates a signed request against CSRF. |
|
318 | - * |
|
319 | - * @param array $data |
|
320 | - * @param string $state |
|
321 | - * |
|
322 | - * @throws FacebookSDKException |
|
323 | - */ |
|
324 | - public static function validateCsrf(array $data, $state) |
|
325 | - { |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Validates a signed request against CSRF. |
|
318 | + * |
|
319 | + * @param array $data |
|
320 | + * @param string $state |
|
321 | + * |
|
322 | + * @throws FacebookSDKException |
|
323 | + */ |
|
324 | + public static function validateCsrf(array $data, $state) |
|
325 | + { |
|
326 | 326 | if (isset($data['state']) && $data['state'] === $state) { |
327 | - return; |
|
327 | + return; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | throw new FacebookSDKException( |
331 | - 'Signed request did not pass CSRF validation.', 604 |
|
331 | + 'Signed request did not pass CSRF validation.', 604 |
|
332 | 332 | ); |
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Base64 decoding which replaces characters: |
|
337 | - * + instead of - |
|
338 | - * / instead of _ |
|
339 | - * @link http://en.wikipedia.org/wiki/Base64#URL_applications |
|
340 | - * |
|
341 | - * @param string $input base64 url encoded input |
|
342 | - * |
|
343 | - * @return string decoded string |
|
344 | - */ |
|
345 | - public static function base64UrlDecode($input) |
|
346 | - { |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Base64 decoding which replaces characters: |
|
337 | + * + instead of - |
|
338 | + * / instead of _ |
|
339 | + * @link http://en.wikipedia.org/wiki/Base64#URL_applications |
|
340 | + * |
|
341 | + * @param string $input base64 url encoded input |
|
342 | + * |
|
343 | + * @return string decoded string |
|
344 | + */ |
|
345 | + public static function base64UrlDecode($input) |
|
346 | + { |
|
347 | 347 | $urlDecodedBase64 = strtr($input, '-_', '+/'); |
348 | 348 | static::validateBase64($urlDecodedBase64); |
349 | 349 | return base64_decode($urlDecodedBase64); |
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Base64 encoding which replaces characters: |
|
354 | - * + instead of - |
|
355 | - * / instead of _ |
|
356 | - * @link http://en.wikipedia.org/wiki/Base64#URL_applications |
|
357 | - * |
|
358 | - * @param string $input string to encode |
|
359 | - * |
|
360 | - * @return string base64 url encoded input |
|
361 | - */ |
|
362 | - public static function base64UrlEncode($input) |
|
363 | - { |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Base64 encoding which replaces characters: |
|
354 | + * + instead of - |
|
355 | + * / instead of _ |
|
356 | + * @link http://en.wikipedia.org/wiki/Base64#URL_applications |
|
357 | + * |
|
358 | + * @param string $input string to encode |
|
359 | + * |
|
360 | + * @return string base64 url encoded input |
|
361 | + */ |
|
362 | + public static function base64UrlEncode($input) |
|
363 | + { |
|
364 | 364 | return strtr(base64_encode($input), '+/', '-_'); |
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Validates a base64 string. |
|
369 | - * |
|
370 | - * @param string $input base64 value to validate |
|
371 | - * |
|
372 | - * @throws FacebookSDKException |
|
373 | - */ |
|
374 | - public static function validateBase64($input) |
|
375 | - { |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Validates a base64 string. |
|
369 | + * |
|
370 | + * @param string $input base64 value to validate |
|
371 | + * |
|
372 | + * @throws FacebookSDKException |
|
373 | + */ |
|
374 | + public static function validateBase64($input) |
|
375 | + { |
|
376 | 376 | $pattern = '/^[a-zA-Z0-9\/\r\n+]*={0,2}$/'; |
377 | 377 | if (preg_match($pattern, $input)) { |
378 | - return; |
|
378 | + return; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | throw new FacebookSDKException( |
382 | - 'Signed request contains malformed base64 encoding.', 608 |
|
382 | + 'Signed request contains malformed base64 encoding.', 608 |
|
383 | 383 | ); |
384 | - } |
|
384 | + } |
|
385 | 385 | |
386 | 386 | } |
@@ -35,120 +35,120 @@ discard block |
||
35 | 35 | class AccessToken |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * The access token. |
|
40 | - * |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $accessToken; |
|
44 | - |
|
45 | - /** |
|
46 | - * A unique ID to identify a client. |
|
47 | - * |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $machineId; |
|
51 | - |
|
52 | - /** |
|
53 | - * Date when token expires. |
|
54 | - * |
|
55 | - * @var \DateTime|null |
|
56 | - */ |
|
57 | - protected $expiresAt; |
|
58 | - |
|
59 | - /** |
|
60 | - * Create a new access token entity. |
|
61 | - * |
|
62 | - * @param string $accessToken |
|
63 | - * @param int $expiresAt |
|
64 | - * @param string|null machineId |
|
65 | - * @param string $machineId |
|
66 | - */ |
|
67 | - public function __construct($accessToken, $expiresAt = 0, $machineId = null) |
|
68 | - { |
|
38 | + /** |
|
39 | + * The access token. |
|
40 | + * |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $accessToken; |
|
44 | + |
|
45 | + /** |
|
46 | + * A unique ID to identify a client. |
|
47 | + * |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $machineId; |
|
51 | + |
|
52 | + /** |
|
53 | + * Date when token expires. |
|
54 | + * |
|
55 | + * @var \DateTime|null |
|
56 | + */ |
|
57 | + protected $expiresAt; |
|
58 | + |
|
59 | + /** |
|
60 | + * Create a new access token entity. |
|
61 | + * |
|
62 | + * @param string $accessToken |
|
63 | + * @param int $expiresAt |
|
64 | + * @param string|null machineId |
|
65 | + * @param string $machineId |
|
66 | + */ |
|
67 | + public function __construct($accessToken, $expiresAt = 0, $machineId = null) |
|
68 | + { |
|
69 | 69 | $this->accessToken = $accessToken; |
70 | 70 | if ($expiresAt) { |
71 | - $this->setExpiresAtFromTimeStamp($expiresAt); |
|
71 | + $this->setExpiresAtFromTimeStamp($expiresAt); |
|
72 | 72 | } |
73 | 73 | $this->machineId = $machineId; |
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Setter for expires_at. |
|
78 | - * |
|
79 | - * @param int $timeStamp |
|
80 | - */ |
|
81 | - protected function setExpiresAtFromTimeStamp($timeStamp) |
|
82 | - { |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Setter for expires_at. |
|
78 | + * |
|
79 | + * @param int $timeStamp |
|
80 | + */ |
|
81 | + protected function setExpiresAtFromTimeStamp($timeStamp) |
|
82 | + { |
|
83 | 83 | $dt = new \DateTime(); |
84 | 84 | $dt->setTimestamp($timeStamp); |
85 | 85 | $this->expiresAt = $dt; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Getter for expiresAt. |
|
90 | - * |
|
91 | - * @return \DateTime|null |
|
92 | - */ |
|
93 | - public function getExpiresAt() |
|
94 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Getter for expiresAt. |
|
90 | + * |
|
91 | + * @return \DateTime|null |
|
92 | + */ |
|
93 | + public function getExpiresAt() |
|
94 | + { |
|
95 | 95 | return $this->expiresAt; |
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Getter for machineId. |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getMachineId() |
|
104 | - { |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Getter for machineId. |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getMachineId() |
|
104 | + { |
|
105 | 105 | return $this->machineId; |
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Determines whether or not this is a long-lived token. |
|
110 | - * |
|
111 | - * @return bool |
|
112 | - */ |
|
113 | - public function isLongLived() |
|
114 | - { |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Determines whether or not this is a long-lived token. |
|
110 | + * |
|
111 | + * @return bool |
|
112 | + */ |
|
113 | + public function isLongLived() |
|
114 | + { |
|
115 | 115 | if ($this->expiresAt) { |
116 | - return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2); |
|
116 | + return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2); |
|
117 | 117 | } |
118 | 118 | return false; |
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Checks the validity of the access token. |
|
123 | - * |
|
124 | - * @param string|null $appId Application ID to use |
|
125 | - * @param string|null $appSecret App secret value to use |
|
126 | - * @param string|null $machineId |
|
127 | - * |
|
128 | - * @return boolean |
|
129 | - */ |
|
130 | - public function isValid($appId = null, $appSecret = null, $machineId = null) |
|
131 | - { |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Checks the validity of the access token. |
|
123 | + * |
|
124 | + * @param string|null $appId Application ID to use |
|
125 | + * @param string|null $appSecret App secret value to use |
|
126 | + * @param string|null $machineId |
|
127 | + * |
|
128 | + * @return boolean |
|
129 | + */ |
|
130 | + public function isValid($appId = null, $appSecret = null, $machineId = null) |
|
131 | + { |
|
132 | 132 | $accessTokenInfo = $this->getInfo($appId, $appSecret); |
133 | 133 | $machineId = $machineId ?: $this->machineId; |
134 | 134 | return static::validateAccessToken($accessTokenInfo, $appId, $machineId); |
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Ensures the provided GraphSessionInfo object is valid, |
|
139 | - * throwing an exception if not. Ensures the appId matches, |
|
140 | - * that the machineId matches if it's being used, |
|
141 | - * that the token is valid and has not expired. |
|
142 | - * |
|
143 | - * @param GraphSessionInfo $tokenInfo |
|
144 | - * @param string|null $appId Application ID to use |
|
145 | - * @param string|null $machineId |
|
146 | - * |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public static function validateAccessToken(GraphSessionInfo $tokenInfo, |
|
150 | - $appId = null, $machineId = null) |
|
151 | - { |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Ensures the provided GraphSessionInfo object is valid, |
|
139 | + * throwing an exception if not. Ensures the appId matches, |
|
140 | + * that the machineId matches if it's being used, |
|
141 | + * that the token is valid and has not expired. |
|
142 | + * |
|
143 | + * @param GraphSessionInfo $tokenInfo |
|
144 | + * @param string|null $appId Application ID to use |
|
145 | + * @param string|null $machineId |
|
146 | + * |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public static function validateAccessToken(GraphSessionInfo $tokenInfo, |
|
150 | + $appId = null, $machineId = null) |
|
151 | + { |
|
152 | 152 | $targetAppId = FacebookSession::_getTargetAppId($appId); |
153 | 153 | |
154 | 154 | $appIdIsValid = $tokenInfo->getAppId() == $targetAppId; |
@@ -157,90 +157,90 @@ discard block |
||
157 | 157 | |
158 | 158 | // Not all access tokens return an expiration. E.g. an app access token. |
159 | 159 | if ($tokenInfo->getExpiresAt() instanceof \DateTime) { |
160 | - $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time(); |
|
160 | + $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time(); |
|
161 | 161 | } else { |
162 | - $accessTokenIsStillAlive = true; |
|
162 | + $accessTokenIsStillAlive = true; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $appIdIsValid && $machineIdIsValid && $accessTokenIsValid && $accessTokenIsStillAlive; |
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Get a valid access token from a code. |
|
170 | - * |
|
171 | - * @param string $code |
|
172 | - * @param string|null $appId |
|
173 | - * @param string|null $appSecret |
|
174 | - * @param string|null $machineId |
|
175 | - * |
|
176 | - * @return AccessToken |
|
177 | - */ |
|
178 | - public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null) |
|
179 | - { |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Get a valid access token from a code. |
|
170 | + * |
|
171 | + * @param string $code |
|
172 | + * @param string|null $appId |
|
173 | + * @param string|null $appSecret |
|
174 | + * @param string|null $machineId |
|
175 | + * |
|
176 | + * @return AccessToken |
|
177 | + */ |
|
178 | + public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null) |
|
179 | + { |
|
180 | 180 | $params = array( |
181 | - 'code' => $code, |
|
182 | - 'redirect_uri' => '', |
|
181 | + 'code' => $code, |
|
182 | + 'redirect_uri' => '', |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | if ($machineId) { |
186 | - $params['machine_id'] = $machineId; |
|
186 | + $params['machine_id'] = $machineId; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return static::requestAccessToken($params, $appId, $appSecret); |
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Get a valid code from an access token. |
|
194 | - * |
|
195 | - * @param AccessToken $accessToken |
|
196 | - * @param string|null $appId |
|
197 | - * @param string|null $appSecret |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null) |
|
202 | - { |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Get a valid code from an access token. |
|
194 | + * |
|
195 | + * @param AccessToken $accessToken |
|
196 | + * @param string|null $appId |
|
197 | + * @param string|null $appSecret |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null) |
|
202 | + { |
|
203 | 203 | $accessToken = (string) $accessToken; |
204 | 204 | |
205 | 205 | $params = array( |
206 | - 'access_token' => $accessToken, |
|
207 | - 'redirect_uri' => '', |
|
206 | + 'access_token' => $accessToken, |
|
207 | + 'redirect_uri' => '', |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | return static::requestCode($params, $appId, $appSecret); |
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Exchanges a short lived access token with a long lived access token. |
|
215 | - * |
|
216 | - * @param string|null $appId |
|
217 | - * @param string|null $appSecret |
|
218 | - * |
|
219 | - * @return AccessToken |
|
220 | - */ |
|
221 | - public function extend($appId = null, $appSecret = null) |
|
222 | - { |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Exchanges a short lived access token with a long lived access token. |
|
215 | + * |
|
216 | + * @param string|null $appId |
|
217 | + * @param string|null $appSecret |
|
218 | + * |
|
219 | + * @return AccessToken |
|
220 | + */ |
|
221 | + public function extend($appId = null, $appSecret = null) |
|
222 | + { |
|
223 | 223 | $params = array( |
224 | - 'grant_type' => 'fb_exchange_token', |
|
225 | - 'fb_exchange_token' => $this->accessToken, |
|
224 | + 'grant_type' => 'fb_exchange_token', |
|
225 | + 'fb_exchange_token' => $this->accessToken, |
|
226 | 226 | ); |
227 | 227 | |
228 | 228 | return static::requestAccessToken($params, $appId, $appSecret); |
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Request an access token based on a set of params. |
|
233 | - * |
|
234 | - * @param array $params |
|
235 | - * @param string|null $appId |
|
236 | - * @param string|null $appSecret |
|
237 | - * |
|
238 | - * @return AccessToken |
|
239 | - * |
|
240 | - * @throws FacebookRequestException |
|
241 | - */ |
|
242 | - public static function requestAccessToken(array $params, $appId = null, $appSecret = null) |
|
243 | - { |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Request an access token based on a set of params. |
|
233 | + * |
|
234 | + * @param array $params |
|
235 | + * @param string|null $appId |
|
236 | + * @param string|null $appSecret |
|
237 | + * |
|
238 | + * @return AccessToken |
|
239 | + * |
|
240 | + * @throws FacebookRequestException |
|
241 | + */ |
|
242 | + public static function requestAccessToken(array $params, $appId = null, $appSecret = null) |
|
243 | + { |
|
244 | 244 | $response = static::request('/oauth/access_token', $params, $appId, $appSecret); |
245 | 245 | $data = $response->getResponse(); |
246 | 246 | |
@@ -249,133 +249,133 @@ discard block |
||
249 | 249 | * @see https://github.com/facebook/facebook-php-sdk-v4/issues/36 |
250 | 250 | */ |
251 | 251 | if (is_array($data)) { |
252 | - if (isset($data['access_token'])) { |
|
252 | + if (isset($data['access_token'])) { |
|
253 | 253 | $expiresAt = isset($data['expires']) ? time() + $data['expires'] : 0; |
254 | 254 | return new static($data['access_token'], $expiresAt); |
255 | - } |
|
255 | + } |
|
256 | 256 | } elseif($data instanceof \stdClass) { |
257 | - if (isset($data->access_token)) { |
|
257 | + if (isset($data->access_token)) { |
|
258 | 258 | $expiresAt = isset($data->expires_in) ? time() + $data->expires_in : 0; |
259 | 259 | $machineId = isset($data->machine_id) ? (string) $data->machine_id : null; |
260 | 260 | return new static((string) $data->access_token, $expiresAt, $machineId); |
261 | - } |
|
261 | + } |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | throw FacebookRequestException::create( |
265 | - $response->getRawResponse(), |
|
266 | - $data, |
|
267 | - 401 |
|
265 | + $response->getRawResponse(), |
|
266 | + $data, |
|
267 | + 401 |
|
268 | 268 | ); |
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Request a code from a long lived access token. |
|
273 | - * |
|
274 | - * @param array $params |
|
275 | - * @param string|null $appId |
|
276 | - * @param string|null $appSecret |
|
277 | - * |
|
278 | - * @return string |
|
279 | - * |
|
280 | - * @throws FacebookRequestException |
|
281 | - */ |
|
282 | - public static function requestCode(array $params, $appId = null, $appSecret = null) |
|
283 | - { |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Request a code from a long lived access token. |
|
273 | + * |
|
274 | + * @param array $params |
|
275 | + * @param string|null $appId |
|
276 | + * @param string|null $appSecret |
|
277 | + * |
|
278 | + * @return string |
|
279 | + * |
|
280 | + * @throws FacebookRequestException |
|
281 | + */ |
|
282 | + public static function requestCode(array $params, $appId = null, $appSecret = null) |
|
283 | + { |
|
284 | 284 | $response = static::request('/oauth/client_code', $params, $appId, $appSecret); |
285 | 285 | $data = $response->getResponse(); |
286 | 286 | |
287 | 287 | if (isset($data->code)) { |
288 | - return (string) $data->code; |
|
288 | + return (string) $data->code; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | throw FacebookRequestException::create( |
292 | - $response->getRawResponse(), |
|
293 | - $data, |
|
294 | - 401 |
|
292 | + $response->getRawResponse(), |
|
293 | + $data, |
|
294 | + 401 |
|
295 | 295 | ); |
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Send a request to Graph with an app access token. |
|
300 | - * |
|
301 | - * @param string $endpoint |
|
302 | - * @param array $params |
|
303 | - * @param string|null $appId |
|
304 | - * @param string|null $appSecret |
|
305 | - * |
|
306 | - * @return \Facebook\FacebookResponse |
|
307 | - * |
|
308 | - * @throws FacebookRequestException |
|
309 | - */ |
|
310 | - protected static function request($endpoint, array $params, $appId = null, $appSecret = null) |
|
311 | - { |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Send a request to Graph with an app access token. |
|
300 | + * |
|
301 | + * @param string $endpoint |
|
302 | + * @param array $params |
|
303 | + * @param string|null $appId |
|
304 | + * @param string|null $appSecret |
|
305 | + * |
|
306 | + * @return \Facebook\FacebookResponse |
|
307 | + * |
|
308 | + * @throws FacebookRequestException |
|
309 | + */ |
|
310 | + protected static function request($endpoint, array $params, $appId = null, $appSecret = null) |
|
311 | + { |
|
312 | 312 | $targetAppId = FacebookSession::_getTargetAppId($appId); |
313 | 313 | $targetAppSecret = FacebookSession::_getTargetAppSecret($appSecret); |
314 | 314 | |
315 | 315 | if (!isset($params['client_id'])) { |
316 | - $params['client_id'] = $targetAppId; |
|
316 | + $params['client_id'] = $targetAppId; |
|
317 | 317 | } |
318 | 318 | if (!isset($params['client_secret'])) { |
319 | - $params['client_secret'] = $targetAppSecret; |
|
319 | + $params['client_secret'] = $targetAppSecret; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // The response for this endpoint is not JSON, so it must be handled |
323 | 323 | // differently, not as a GraphObject. |
324 | 324 | $request = new FacebookRequest( |
325 | - FacebookSession::newAppSession($targetAppId, $targetAppSecret), |
|
326 | - 'GET', |
|
327 | - $endpoint, |
|
328 | - $params |
|
325 | + FacebookSession::newAppSession($targetAppId, $targetAppSecret), |
|
326 | + 'GET', |
|
327 | + $endpoint, |
|
328 | + $params |
|
329 | 329 | ); |
330 | 330 | return $request->execute(); |
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * Get more info about an access token. |
|
335 | - * |
|
336 | - * @param string|null $appId |
|
337 | - * @param string|null $appSecret |
|
338 | - * |
|
339 | - * @return GraphSessionInfo |
|
340 | - */ |
|
341 | - public function getInfo($appId = null, $appSecret = null) |
|
342 | - { |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * Get more info about an access token. |
|
335 | + * |
|
336 | + * @param string|null $appId |
|
337 | + * @param string|null $appSecret |
|
338 | + * |
|
339 | + * @return GraphSessionInfo |
|
340 | + */ |
|
341 | + public function getInfo($appId = null, $appSecret = null) |
|
342 | + { |
|
343 | 343 | $params = array('input_token' => $this->accessToken); |
344 | 344 | |
345 | 345 | $request = new FacebookRequest( |
346 | - FacebookSession::newAppSession($appId, $appSecret), |
|
347 | - 'GET', |
|
348 | - '/debug_token', |
|
349 | - $params |
|
346 | + FacebookSession::newAppSession($appId, $appSecret), |
|
347 | + 'GET', |
|
348 | + '/debug_token', |
|
349 | + $params |
|
350 | 350 | ); |
351 | 351 | $response = $request->execute()->getGraphObject(GraphSessionInfo::className()); |
352 | 352 | |
353 | 353 | // Update the data on this token |
354 | 354 | if ($response->getExpiresAt()) { |
355 | - $this->expiresAt = $response->getExpiresAt(); |
|
355 | + $this->expiresAt = $response->getExpiresAt(); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $response; |
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Returns the access token as a string. |
|
363 | - * |
|
364 | - * @return string |
|
365 | - */ |
|
366 | - public function __toString() |
|
367 | - { |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Returns the access token as a string. |
|
363 | + * |
|
364 | + * @return string |
|
365 | + */ |
|
366 | + public function __toString() |
|
367 | + { |
|
368 | 368 | return $this->accessToken; |
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Returns true if the access token is an app session token. |
|
373 | - * |
|
374 | - * @return bool |
|
375 | - */ |
|
376 | - public function isAppSession() |
|
377 | - { |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Returns true if the access token is an app session token. |
|
373 | + * |
|
374 | + * @return bool |
|
375 | + */ |
|
376 | + public function isAppSession() |
|
377 | + { |
|
378 | 378 | return strpos($this->accessToken, "|") !== false; |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | //path for svg-edit save |
44 | 44 | $_SESSION['draw_dir'] = Security::remove_XSS($dir); |
45 | 45 | if ($_SESSION['draw_dir'] == '/') { |
46 | - $_SESSION['draw_dir'] = ''; |
|
46 | + $_SESSION['draw_dir'] = ''; |
|
47 | 47 | } |
48 | 48 | $_SESSION['draw_file'] = basename(Security::remove_XSS($file_path)); |
49 | 49 | $get_file = Security::remove_XSS($file_path); |
@@ -59,26 +59,26 @@ discard block |
||
59 | 59 | /* Please, do not modify this dirname formatting */ |
60 | 60 | |
61 | 61 | if (strstr($dir, '..')) { |
62 | - $dir = '/'; |
|
62 | + $dir = '/'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | if ($dir[0] == '.') { |
66 | - $dir = substr($dir, 1); |
|
66 | + $dir = substr($dir, 1); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if ($dir[0] != '/') { |
70 | - $dir = '/'.$dir; |
|
70 | + $dir = '/'.$dir; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | if ($dir[strlen($dir) - 1] != '/') { |
74 | - $dir .= '/'; |
|
74 | + $dir .= '/'; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
78 | 78 | |
79 | 79 | if (!is_dir($filepath)) { |
80 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
81 | - $dir = '/'; |
|
80 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
81 | + $dir = '/'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | //groups //TODO:clean |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
88 | 88 | 'name' => get_lang('GroupSpace'), |
89 | 89 | ); |
90 | - $group_document = true; |
|
91 | - $noPHP_SELF = true; |
|
90 | + $group_document = true; |
|
91 | + $noPHP_SELF = true; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | $is_certificate_mode = DocumentManager::is_certificate_mode($dir); |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || |
117 | - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
117 | + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
118 | 118 | |
119 | 119 | if (!$is_allowedToEdit) { |
120 | - api_not_allowed(true); |
|
120 | + api_not_allowed(true); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | Event::event_access_tool(TOOL_DOCUMENT); |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | echo '</div>'; |
132 | 132 | |
133 | 133 | if (api_browser_support('svg')) { |
134 | - //automatic loading the course language |
|
135 | - $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
136 | - $langsvgedit = api_get_language_isocode(); |
|
137 | - $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
138 | - $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
139 | - $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; |
|
140 | - ?> |
|
134 | + //automatic loading the course language |
|
135 | + $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
136 | + $langsvgedit = api_get_language_isocode(); |
|
137 | + $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
138 | + $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
139 | + $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; |
|
140 | + ?> |
|
141 | 141 | <script> |
142 | 142 | document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'); |
143 | 143 | function resizeIframe() { |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | <?php |
157 | 157 | echo '<noscript>'; |
158 | - echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
159 | - echo '</noscript>'; |
|
158 | + echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
159 | + echo '</noscript>'; |
|
160 | 160 | } else { |
161 | - Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
161 | + Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
162 | 162 | } |
163 | 163 | Display::display_footer(); |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class ExerciseShowFunctions |
19 | 19 | { |
20 | - /** |
|
21 | - * Shows the answer to a fill-in-the-blanks question, as HTML |
|
20 | + /** |
|
21 | + * Shows the answer to a fill-in-the-blanks question, as HTML |
|
22 | 22 | * @param int $feedbackType |
23 | - * @param string $answer |
|
24 | - * @param int $id Exercise ID |
|
25 | - * @param int $questionId Question ID |
|
23 | + * @param string $answer |
|
24 | + * @param int $id Exercise ID |
|
25 | + * @param int $questionId Question ID |
|
26 | 26 | * @param int $resultsDisabled |
27 | 27 | * @param string $originalStudentAnswer |
28 | 28 | * |
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function display_fill_in_blanks_answer( |
|
32 | - $feedbackType, |
|
33 | - $answer, |
|
34 | - $id, |
|
35 | - $questionId, |
|
36 | - $resultsDisabled, |
|
37 | - $originalStudentAnswer = '', |
|
38 | - $showTotalScoreAndUserChoices |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function display_fill_in_blanks_answer( |
|
32 | + $feedbackType, |
|
33 | + $answer, |
|
34 | + $id, |
|
35 | + $questionId, |
|
36 | + $resultsDisabled, |
|
37 | + $originalStudentAnswer = '', |
|
38 | + $showTotalScoreAndUserChoices |
|
39 | 39 | ) { |
40 | 40 | $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled, $showTotalScoreAndUserChoices); |
41 | 41 | if (strpos($originalStudentAnswer, 'font color') !== false) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | </tr> |
65 | 65 | <?php |
66 | 66 | } |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Shows the answer to a calculated question, as HTML |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Shows the answer to a free-answer question, as HTML |
|
110 | - * @param string Answer text |
|
111 | - * @param int Exercise ID |
|
112 | - * @param int Question ID |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public static function display_free_answer( |
|
116 | - $feedback_type, |
|
117 | - $answer, |
|
118 | - $exe_id, |
|
119 | - $questionId, |
|
120 | - $questionScore = null, |
|
121 | - $results_disabled = 0 |
|
108 | + /** |
|
109 | + * Shows the answer to a free-answer question, as HTML |
|
110 | + * @param string Answer text |
|
111 | + * @param int Exercise ID |
|
112 | + * @param int Question ID |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public static function display_free_answer( |
|
116 | + $feedback_type, |
|
117 | + $answer, |
|
118 | + $exe_id, |
|
119 | + $questionId, |
|
120 | + $questionScore = null, |
|
121 | + $results_disabled = 0 |
|
122 | 122 | ) { |
123 | 123 | $comments = Event::get_comments($exe_id, $questionId); |
124 | 124 | |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | echo '</tr>'; |
137 | 137 | } |
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | - * @param $feedback_type |
|
143 | - * @param $answer |
|
144 | - * @param $id |
|
145 | - * @param $questionId |
|
146 | - * @param null $nano |
|
147 | - * @param int $results_disabled |
|
142 | + * @param $feedback_type |
|
143 | + * @param $answer |
|
144 | + * @param $id |
|
145 | + * @param $questionId |
|
146 | + * @param null $nano |
|
147 | + * @param int $results_disabled |
|
148 | 148 | */ |
149 | - public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) |
|
149 | + public static function display_oral_expression_answer($feedback_type, $answer, $id, $questionId, $fileUrl = null, $results_disabled = 0) |
|
150 | 150 | { |
151 | 151 | if (isset($fileUrl)) { |
152 | 152 | echo ' |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - /** |
|
188 | - * Displays the answer to a hotspot question |
|
187 | + /** |
|
188 | + * Displays the answer to a hotspot question |
|
189 | 189 | * @param int $feedback_type |
190 | 190 | * @param int $answerId |
191 | 191 | * @param string $answer |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param int $resultsDisabled |
195 | 195 | * @param int $orderColor |
196 | 196 | */ |
197 | - public static function display_hotspot_answer( |
|
197 | + public static function display_hotspot_answer( |
|
198 | 198 | $feedback_type, |
199 | 199 | $answerId, |
200 | 200 | $answer, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - $hotspot_colors = array( |
|
220 | + $hotspot_colors = array( |
|
221 | 221 | "", // $i starts from 1 on next loop (ugly fix) |
222 | 222 | "#4271B5", |
223 | 223 | "#FE8E16", |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | "#F7BDE2" |
235 | 235 | ); |
236 | 236 | |
237 | - ?> |
|
237 | + ?> |
|
238 | 238 | <table class="data_table"> |
239 | 239 | <tr> |
240 | 240 | <td class="text-center" width="5%"> |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | <td class="text-left" width="10%"> |
247 | 247 | <?php |
248 | 248 | if (!$hide_expected_answer) { |
249 | - $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
250 | - echo $my_choice; |
|
249 | + $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
250 | + echo $my_choice; |
|
251 | 251 | } |
252 | - ?> |
|
252 | + ?> |
|
253 | 253 | </td> |
254 | 254 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
255 | 255 | <td class="text-left" width="60%"> |
@@ -257,29 +257,29 @@ discard block |
||
257 | 257 | if ($studentChoice) { |
258 | 258 | echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
259 | 259 | } |
260 | - ?> |
|
260 | + ?> |
|
261 | 261 | </td> |
262 | 262 | <?php } else { ?> |
263 | 263 | <td class="text-left" width="60%"> </td> |
264 | 264 | <?php } ?> |
265 | 265 | </tr> |
266 | 266 | <?php |
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Display the answers to a multiple choice question |
|
271 | - * @param int $feedback_type Feedback type |
|
272 | - * @param integer Answer type |
|
273 | - * @param integer Student choice |
|
274 | - * @param string Textual answer |
|
275 | - * @param string Comment on answer |
|
276 | - * @param string Correct answer comment |
|
277 | - * @param integer Exercise ID |
|
278 | - * @param integer Question ID |
|
279 | - * @param boolean Whether to show the answer comment or not |
|
280 | - * @return void |
|
281 | - */ |
|
282 | - public static function display_unique_or_multiple_answer( |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Display the answers to a multiple choice question |
|
271 | + * @param int $feedback_type Feedback type |
|
272 | + * @param integer Answer type |
|
273 | + * @param integer Student choice |
|
274 | + * @param string Textual answer |
|
275 | + * @param string Comment on answer |
|
276 | + * @param string Correct answer comment |
|
277 | + * @param integer Exercise ID |
|
278 | + * @param integer Question ID |
|
279 | + * @param boolean Whether to show the answer comment or not |
|
280 | + * @return void |
|
281 | + */ |
|
282 | + public static function display_unique_or_multiple_answer( |
|
283 | 283 | $feedback_type, |
284 | 284 | $answerType, |
285 | 285 | $studentChoice, |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | $icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
310 | - $icon .= $studentChoice?'_on':'_off'; |
|
311 | - $icon .= '.gif'; |
|
310 | + $icon .= $studentChoice?'_on':'_off'; |
|
311 | + $icon .= '.gif'; |
|
312 | 312 | |
313 | - $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
314 | - $iconAnswer .= $answerCorrect?'_on':'_off'; |
|
315 | - $iconAnswer .= '.gif'; |
|
313 | + $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
314 | + $iconAnswer .= $answerCorrect?'_on':'_off'; |
|
315 | + $iconAnswer .= '.gif'; |
|
316 | 316 | |
317 | - ?> |
|
317 | + ?> |
|
318 | 318 | <tr> |
319 | 319 | <td width="5%"> |
320 | 320 | <?php echo Display::return_icon($icon); ?> |
@@ -328,39 +328,39 @@ discard block |
||
328 | 328 | </td> |
329 | 329 | <td width="40%"> |
330 | 330 | <?php |
331 | - echo $answer; |
|
332 | - ?> |
|
331 | + echo $answer; |
|
332 | + ?> |
|
333 | 333 | </td> |
334 | 334 | |
335 | 335 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
336 | 336 | <td width="20%"> |
337 | 337 | <?php |
338 | 338 | if ($studentChoice) { |
339 | - if ($answerCorrect) { |
|
339 | + if ($answerCorrect) { |
|
340 | 340 | $color = 'green'; |
341 | - //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
342 | - } else { |
|
341 | + //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
342 | + } else { |
|
343 | 343 | $color = 'black'; |
344 | 344 | //echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>'; |
345 | - } |
|
346 | - if ($hide_expected_answer) { |
|
347 | - $color = ''; |
|
348 | - } |
|
345 | + } |
|
346 | + if ($hide_expected_answer) { |
|
347 | + $color = ''; |
|
348 | + } |
|
349 | 349 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
350 | - } |
|
351 | - ?> |
|
350 | + } |
|
351 | + ?> |
|
352 | 352 | </td> |
353 | 353 | <?php |
354 | - if ($ans==1) { |
|
355 | - $comm = Event::get_comments($id,$questionId); |
|
356 | - } |
|
357 | - ?> |
|
354 | + if ($ans==1) { |
|
355 | + $comm = Event::get_comments($id,$questionId); |
|
356 | + } |
|
357 | + ?> |
|
358 | 358 | <?php } else { ?> |
359 | 359 | <td> </td> |
360 | 360 | <?php } ?> |
361 | 361 | </tr> |
362 | 362 | <?php |
363 | - } |
|
363 | + } |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Display the answers to a multiple choice question |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (isset($new_options[$studentChoice])) { |
414 | 414 | echo get_lang($new_options[$studentChoice]['name']); |
415 | 415 | } else { |
416 | - echo '-'; |
|
416 | + echo '-'; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | ?> |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | <td width="5%"> |
422 | 422 | <?php |
423 | 423 | |
424 | - //Expected choice |
|
424 | + //Expected choice |
|
425 | 425 | if (!$hide_expected_answer) { |
426 | 426 | if (isset($new_options[$answerCorrect])) { |
427 | 427 | echo get_lang($new_options[$answerCorrect]['name']); |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | if ($hide_expected_answer) { |
450 | - $color = ''; |
|
451 | - } |
|
450 | + $color = ''; |
|
451 | + } |
|
452 | 452 | |
453 | 453 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
454 | 454 | } |
@@ -466,19 +466,19 @@ discard block |
||
466 | 466 | <?php |
467 | 467 | } |
468 | 468 | |
469 | - /** |
|
470 | - * Display the answers to a multiple choice question |
|
471 | - * |
|
472 | - * @param integer Answer type |
|
473 | - * @param integer Student choice |
|
474 | - * @param string Textual answer |
|
475 | - * @param string Comment on answer |
|
476 | - * @param string Correct answer comment |
|
477 | - * @param integer Exercise ID |
|
478 | - * @param integer Question ID |
|
479 | - * @param boolean Whether to show the answer comment or not |
|
480 | - * @return void |
|
481 | - */ |
|
469 | + /** |
|
470 | + * Display the answers to a multiple choice question |
|
471 | + * |
|
472 | + * @param integer Answer type |
|
473 | + * @param integer Student choice |
|
474 | + * @param string Textual answer |
|
475 | + * @param string Comment on answer |
|
476 | + * @param string Correct answer comment |
|
477 | + * @param integer Exercise ID |
|
478 | + * @param integer Question ID |
|
479 | + * @param boolean Whether to show the answer comment or not |
|
480 | + * @return void |
|
481 | + */ |
|
482 | 482 | public static function display_multiple_answer_combination_true_false( |
483 | 483 | $feedback_type, |
484 | 484 | $answerType, |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | <tr> |
510 | 510 | <td width="5%"> |
511 | 511 | <?php |
512 | - //Your choice |
|
512 | + //Your choice |
|
513 | 513 | $question = new MultipleAnswerCombinationTrueFalse(); |
514 | 514 | if (isset($question->options[$studentChoice])) { |
515 | 515 | echo $question->options[$studentChoice]; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | </td> |
521 | 521 | <td width="5%"> |
522 | 522 | <?php |
523 | - //Expected choice |
|
523 | + //Expected choice |
|
524 | 524 | if (!$hide_expected_answer) { |
525 | 525 | if (isset($question->options[$answerCorrect])) { |
526 | 526 | echo $question->options[$answerCorrect]; |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | <?php |
546 | 546 | //@todo replace this harcoded value |
547 | 547 | if ($studentChoice) { |
548 | - $color = "black"; |
|
548 | + $color = "black"; |
|
549 | 549 | if ($studentChoice == $answerCorrect) { |
550 | 550 | $color = "green"; |
551 | 551 | } |
552 | - //echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>'; |
|
552 | + //echo '<span style="font-weight: bold; color: #000;">'.nl2br($answerComment).'</span>'; |
|
553 | 553 | if ($hide_expected_answer) { |
554 | 554 | $color = ''; |
555 | - } |
|
555 | + } |
|
556 | 556 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
557 | 557 | } |
558 | 558 | ?> |
@@ -582,7 +582,7 @@ |
||
582 | 582 | false |
583 | 583 | ); |
584 | 584 | |
585 | - Display::addFlash( |
|
585 | + Display::addFlash( |
|
586 | 586 | Display::return_message("Copying {$absolute_template_datadir}/data/archive => $archivePath") |
587 | 587 | ); |
588 | 588 | copyDirTo( |