@@ -61,44 +61,44 @@ discard block |
||
61 | 61 | /* Please, do not modify this dirname formatting */ |
62 | 62 | |
63 | 63 | if (strstr($dir, '..')) { |
64 | - $dir = '/'; |
|
64 | + $dir = '/'; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($dir[0] == '.') { |
68 | - $dir = substr($dir, 1); |
|
68 | + $dir = substr($dir, 1); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($dir[0] != '/') { |
72 | - $dir = '/'.$dir; |
|
72 | + $dir = '/'.$dir; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($dir[strlen($dir) - 1] != '/') { |
76 | - $dir .= '/'; |
|
76 | + $dir .= '/'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
80 | 80 | |
81 | 81 | if (!is_dir($filepath)) { |
82 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
83 | - $dir = '/'; |
|
82 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
83 | + $dir = '/'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | //groups //TODO:clean |
87 | 87 | if (!empty($groupId)) { |
88 | - $interbreadcrumb[] = array( |
|
89 | - 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
|
90 | - 'name' => get_lang('GroupSpace'), |
|
91 | - ); |
|
92 | - $group_document = true; |
|
93 | - $noPHP_SELF = true; |
|
88 | + $interbreadcrumb[] = array( |
|
89 | + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
|
90 | + 'name' => get_lang('GroupSpace'), |
|
91 | + ); |
|
92 | + $group_document = true; |
|
93 | + $noPHP_SELF = true; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $is_certificate_mode = DocumentManager::is_certificate_mode($dir); |
97 | 97 | |
98 | 98 | if (!$is_certificate_mode) |
99 | - $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents')); |
|
99 | + $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents')); |
|
100 | 100 | else |
101 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
101 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
102 | 102 | |
103 | 103 | // Interbreadcrumb for the current directory root path |
104 | 104 | if (empty($document_data['parents'])) { |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] || |
116 | - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
116 | + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
117 | 117 | |
118 | 118 | if (!$is_allowedToEdit) { |
119 | - api_not_allowed(true); |
|
119 | + api_not_allowed(true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | Event::event_access_tool(TOOL_DOCUMENT); |
@@ -148,21 +148,21 @@ discard block |
||
148 | 148 | $locktitle="false"; |
149 | 149 | |
150 | 150 | if ($_SERVER['HTTP_HOST']=="localhost") { |
151 | - $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml'; |
|
152 | - if (!file_exists($path_and_file)) { |
|
153 | - $crossdomain='<?xml version="1.0"?> |
|
151 | + $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml'; |
|
152 | + if (!file_exists($path_and_file)) { |
|
153 | + $crossdomain='<?xml version="1.0"?> |
|
154 | 154 | <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> |
155 | 155 | <cross-domain-policy> |
156 | 156 | <allow-access-from domain="cdn.pixlr.com" /> |
157 | 157 | <site-control permitted-cross-domain-policies="master-only"/> |
158 | 158 | <allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/> |
159 | 159 | </cross-domain-policy>';//more open domain="*" |
160 | - @file_put_contents($path_and_file, $crossdomain); |
|
161 | - } |
|
162 | - $credentials="true"; |
|
160 | + @file_put_contents($path_and_file, $crossdomain); |
|
161 | + } |
|
162 | + $credentials="true"; |
|
163 | 163 | } |
164 | 164 | else { |
165 | - $credentials="false"; |
|
165 | + $credentials="false"; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | //make temp images |
@@ -175,23 +175,23 @@ discard block |
||
175 | 175 | $htaccess=api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess'; |
176 | 176 | if (!file_exists($htaccess)) { |
177 | 177 | |
178 | - $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes"; |
|
178 | + $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes"; |
|
179 | 179 | |
180 | - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); |
|
181 | - if ($fp) { |
|
182 | - fwrite($fp, $htaccess_content); |
|
183 | - fclose($fp); |
|
184 | - } |
|
180 | + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); |
|
181 | + if ($fp) { |
|
182 | + fwrite($fp, $htaccess_content); |
|
183 | + fclose($fp); |
|
184 | + } |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $html_index=api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html'; |
188 | 188 | if (!file_exists($html_index)) { |
189 | - $html_index_content="<html><head></head><body></body></html>"; |
|
190 | - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); |
|
191 | - if ($fp) { |
|
192 | - fwrite($fp, $html_index_content); |
|
193 | - fclose($fp); |
|
194 | - } |
|
189 | + $html_index_content="<html><head></head><body></body></html>"; |
|
190 | + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); |
|
191 | + if ($fp) { |
|
192 | + fwrite($fp, $html_index_content); |
|
193 | + fclose($fp); |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | //encript temp name file |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | public function &addElement($element) |
631 | 631 | { |
632 | 632 | if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { |
633 | - $elementObject = &$element; |
|
634 | - $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
633 | + $elementObject = &$element; |
|
634 | + $elementObject->onQuickFormEvent('updateValue', null, $this); |
|
635 | 635 | } else { |
636 | 636 | $args = func_get_args(); |
637 | 637 | $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); |
@@ -676,22 +676,22 @@ discard block |
||
676 | 676 | // }}} |
677 | 677 | // {{{ insertElementBefore() |
678 | 678 | |
679 | - /** |
|
680 | - * Inserts a new element right before the other element |
|
681 | - * |
|
682 | - * Warning: it is not possible to check whether the $element is already |
|
683 | - * added to the form, therefore if you want to move the existing form |
|
684 | - * element to a new position, you'll have to use removeElement(): |
|
685 | - * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
686 | - * |
|
687 | - * @access public |
|
688 | - * @since 3.2.4 |
|
689 | - * @param HTML_QuickForm_element Element to insert |
|
690 | - * @param string Name of the element before which the new |
|
691 | - * one is inserted |
|
692 | - * @return HTML_QuickForm_element reference to inserted element |
|
693 | - * @throws HTML_QuickForm_Error |
|
694 | - */ |
|
679 | + /** |
|
680 | + * Inserts a new element right before the other element |
|
681 | + * |
|
682 | + * Warning: it is not possible to check whether the $element is already |
|
683 | + * added to the form, therefore if you want to move the existing form |
|
684 | + * element to a new position, you'll have to use removeElement(): |
|
685 | + * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); |
|
686 | + * |
|
687 | + * @access public |
|
688 | + * @since 3.2.4 |
|
689 | + * @param HTML_QuickForm_element Element to insert |
|
690 | + * @param string Name of the element before which the new |
|
691 | + * one is inserted |
|
692 | + * @return HTML_QuickForm_element reference to inserted element |
|
693 | + * @throws HTML_QuickForm_Error |
|
694 | + */ |
|
695 | 695 | function &insertElementBefore(&$element, $nameAfter) |
696 | 696 | { |
697 | 697 | if (!empty($this->_duplicateIndex[$nameAfter])) { |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { |
871 | 871 | $props = array('name', 'type', 'size', 'tmp_name', 'error'); |
872 | 872 | $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . |
873 | - " return null;\n" . |
|
874 | - "} else {\n" . |
|
875 | - " \$v = array();\n"; |
|
873 | + " return null;\n" . |
|
874 | + "} else {\n" . |
|
875 | + " \$v = array();\n"; |
|
876 | 876 | foreach ($props as $prop) { |
877 | 877 | $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; |
878 | 878 | } |
@@ -917,13 +917,13 @@ discard block |
||
917 | 917 | return $value; |
918 | 918 | } |
919 | 919 | |
920 | - /** |
|
921 | - * A helper function to change the indexes in $_FILES array |
|
922 | - * |
|
923 | - * @param mixed Some value from the $_FILES array |
|
924 | - * @param string The key from the $_FILES array that should be appended |
|
925 | - * @return array |
|
926 | - */ |
|
920 | + /** |
|
921 | + * A helper function to change the indexes in $_FILES array |
|
922 | + * |
|
923 | + * @param mixed Some value from the $_FILES array |
|
924 | + * @param string The key from the $_FILES array that should be appended |
|
925 | + * @return array |
|
926 | + */ |
|
927 | 927 | function _reindexFiles($value, $key) |
928 | 928 | { |
929 | 929 | if (!is_array($value)) { |
@@ -976,27 +976,27 @@ discard block |
||
976 | 976 | } |
977 | 977 | } // end func setElementError |
978 | 978 | |
979 | - // }}} |
|
980 | - // {{{ getElementType() |
|
981 | - |
|
982 | - /** |
|
983 | - * Returns the type of the given element |
|
984 | - * |
|
985 | - * @param string $element Name of form element |
|
986 | - * @since 1.1 |
|
987 | - * @access public |
|
988 | - * @return string Type of the element, false if the element is not found |
|
989 | - */ |
|
990 | - function getElementType($element) |
|
991 | - { |
|
992 | - if (isset($this->_elementIndex[$element])) { |
|
993 | - return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
994 | - } |
|
995 | - return false; |
|
996 | - } // end func getElementType |
|
997 | - |
|
998 | - // }}} |
|
999 | - // {{{ updateElementAttr() |
|
979 | + // }}} |
|
980 | + // {{{ getElementType() |
|
981 | + |
|
982 | + /** |
|
983 | + * Returns the type of the given element |
|
984 | + * |
|
985 | + * @param string $element Name of form element |
|
986 | + * @since 1.1 |
|
987 | + * @access public |
|
988 | + * @return string Type of the element, false if the element is not found |
|
989 | + */ |
|
990 | + function getElementType($element) |
|
991 | + { |
|
992 | + if (isset($this->_elementIndex[$element])) { |
|
993 | + return $this->_elements[$this->_elementIndex[$element]]->getType(); |
|
994 | + } |
|
995 | + return false; |
|
996 | + } // end func getElementType |
|
997 | + |
|
998 | + // }}} |
|
999 | + // {{{ updateElementAttr() |
|
1000 | 1000 | |
1001 | 1001 | /** |
1002 | 1002 | * Updates Attributes for one or more elements |
@@ -1263,18 +1263,18 @@ discard block |
||
1263 | 1263 | // }}} |
1264 | 1264 | // {{{ addFormRule() |
1265 | 1265 | |
1266 | - /** |
|
1267 | - * Adds a global validation rule |
|
1268 | - * |
|
1269 | - * This should be used when for a rule involving several fields or if |
|
1270 | - * you want to use some completely custom validation for your form. |
|
1271 | - * The rule function/method should return true in case of successful |
|
1272 | - * validation and array('element name' => 'error') when there were errors. |
|
1273 | - * |
|
1274 | - * @access public |
|
1275 | - * @param mixed Callback, either function name or array(&$object, 'method') |
|
1276 | - * @throws HTML_QuickForm_Error |
|
1277 | - */ |
|
1266 | + /** |
|
1267 | + * Adds a global validation rule |
|
1268 | + * |
|
1269 | + * This should be used when for a rule involving several fields or if |
|
1270 | + * you want to use some completely custom validation for your form. |
|
1271 | + * The rule function/method should return true in case of successful |
|
1272 | + * validation and array('element name' => 'error') when there were errors. |
|
1273 | + * |
|
1274 | + * @access public |
|
1275 | + * @param mixed Callback, either function name or array(&$object, 'method') |
|
1276 | + * @throws HTML_QuickForm_Error |
|
1277 | + */ |
|
1278 | 1278 | function addFormRule($rule) |
1279 | 1279 | { |
1280 | 1280 | if (!is_callable($rule)) { |
@@ -1351,18 +1351,18 @@ discard block |
||
1351 | 1351 | // }}} |
1352 | 1352 | // {{{ arrayMerge() |
1353 | 1353 | |
1354 | - /** |
|
1355 | - * Merges two arrays |
|
1356 | - * |
|
1357 | - * Merges two array like the PHP function array_merge but recursively. |
|
1358 | - * The main difference is that existing keys will not be renumbered |
|
1359 | - * if they are integers. |
|
1360 | - * |
|
1361 | - * @access public |
|
1362 | - * @param array $a original array |
|
1363 | - * @param array $b array which will be merged into first one |
|
1364 | - * @return array merged array |
|
1365 | - */ |
|
1354 | + /** |
|
1355 | + * Merges two arrays |
|
1356 | + * |
|
1357 | + * Merges two array like the PHP function array_merge but recursively. |
|
1358 | + * The main difference is that existing keys will not be renumbered |
|
1359 | + * if they are integers. |
|
1360 | + * |
|
1361 | + * @access public |
|
1362 | + * @param array $a original array |
|
1363 | + * @param array $b array which will be merged into first one |
|
1364 | + * @return array merged array |
|
1365 | + */ |
|
1366 | 1366 | static function arrayMerge($a, $b) |
1367 | 1367 | { |
1368 | 1368 | foreach ($b as $k => $v) { |
@@ -1493,10 +1493,10 @@ discard block |
||
1493 | 1493 | */ |
1494 | 1494 | function isElementFrozen($element) |
1495 | 1495 | { |
1496 | - if (isset($this->_elementIndex[$element])) { |
|
1497 | - return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
1498 | - } |
|
1499 | - return false; |
|
1496 | + if (isset($this->_elementIndex[$element])) { |
|
1497 | + return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); |
|
1498 | + } |
|
1499 | + return false; |
|
1500 | 1500 | } // end func isElementFrozen |
1501 | 1501 | |
1502 | 1502 | // }}} |
@@ -1685,7 +1685,7 @@ discard block |
||
1685 | 1685 | */ |
1686 | 1686 | function isFrozen() |
1687 | 1687 | { |
1688 | - return $this->_freezeAll; |
|
1688 | + return $this->_freezeAll; |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | /** |
@@ -1707,14 +1707,14 @@ discard block |
||
1707 | 1707 | return call_user_func($callback, $values); |
1708 | 1708 | } |
1709 | 1709 | |
1710 | - /** |
|
1711 | - * Accepts a renderer |
|
1712 | - * |
|
1713 | - * @param object An HTML_QuickForm_Renderer object |
|
1714 | - * @since 3.0 |
|
1715 | - * @access public |
|
1716 | - * @return void |
|
1717 | - */ |
|
1710 | + /** |
|
1711 | + * Accepts a renderer |
|
1712 | + * |
|
1713 | + * @param object An HTML_QuickForm_Renderer object |
|
1714 | + * @since 3.0 |
|
1715 | + * @access public |
|
1716 | + * @return void |
|
1717 | + */ |
|
1718 | 1718 | function accept(&$renderer) { |
1719 | 1719 | $renderer->startForm($this); |
1720 | 1720 | foreach (array_keys($this->_elements) as $key) { |
@@ -1727,13 +1727,13 @@ discard block |
||
1727 | 1727 | $renderer->finishForm($this); |
1728 | 1728 | } |
1729 | 1729 | |
1730 | - /** |
|
1731 | - * Returns a reference to default renderer object |
|
1732 | - * |
|
1733 | - * @access public |
|
1734 | - * @since 3.0 |
|
1735 | - * @return HTML_QuickForm_Renderer_Default |
|
1736 | - */ |
|
1730 | + /** |
|
1731 | + * Returns a reference to default renderer object |
|
1732 | + * |
|
1733 | + * @access public |
|
1734 | + * @since 3.0 |
|
1735 | + * @return HTML_QuickForm_Renderer_Default |
|
1736 | + */ |
|
1737 | 1737 | function &defaultRenderer() { |
1738 | 1738 | if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { |
1739 | 1739 | // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3 |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | // |
1890 | 1890 | $this->accept($renderer); |
1891 | 1891 | return $renderer->toArray(); |
1892 | - } |
|
1892 | + } |
|
1893 | 1893 | |
1894 | 1894 | /** |
1895 | 1895 | * Returns a 'safe' element's value |
@@ -1961,15 +1961,15 @@ discard block |
||
1961 | 1961 | return $values; |
1962 | 1962 | } |
1963 | 1963 | |
1964 | - /** |
|
1965 | - * Tells whether the form was already submitted |
|
1966 | - * |
|
1967 | - * This is useful since the _submitFiles and _submitValues arrays |
|
1968 | - * may be completely empty after the trackSubmit value is removed. |
|
1969 | - * |
|
1970 | - * @access public |
|
1971 | - * @return bool |
|
1972 | - */ |
|
1964 | + /** |
|
1965 | + * Tells whether the form was already submitted |
|
1966 | + * |
|
1967 | + * This is useful since the _submitFiles and _submitValues arrays |
|
1968 | + * may be completely empty after the trackSubmit value is removed. |
|
1969 | + * |
|
1970 | + * @access public |
|
1971 | + * @return bool |
|
1972 | + */ |
|
1973 | 1973 | function isSubmitted() |
1974 | 1974 | { |
1975 | 1975 | return $this->_flagSubmitted; |
@@ -2056,21 +2056,21 @@ discard block |
||
2056 | 2056 | { |
2057 | 2057 | |
2058 | 2058 | /** |
2059 | - * Prefix for all error messages |
|
2060 | - * @var string |
|
2061 | - */ |
|
2059 | + * Prefix for all error messages |
|
2060 | + * @var string |
|
2061 | + */ |
|
2062 | 2062 | var $error_message_prefix = 'QuickForm Error: '; |
2063 | 2063 | |
2064 | 2064 | /** |
2065 | - * Creates a quickform error object, extending the PEAR_Error class |
|
2066 | - * |
|
2067 | - * @param int $code the error code |
|
2068 | - * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
2069 | - * @param int $level intensity of the error (PHP error code) |
|
2070 | - * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
2071 | - */ |
|
2065 | + * Creates a quickform error object, extending the PEAR_Error class |
|
2066 | + * |
|
2067 | + * @param int $code the error code |
|
2068 | + * @param int $mode the reaction to the error, either return, die or trigger/callback |
|
2069 | + * @param int $level intensity of the error (PHP error code) |
|
2070 | + * @param mixed $debuginfo any information that can inform user as to nature of the error |
|
2071 | + */ |
|
2072 | 2072 | function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, |
2073 | - $level = E_USER_NOTICE, $debuginfo = null) |
|
2073 | + $level = E_USER_NOTICE, $debuginfo = null) |
|
2074 | 2074 | { |
2075 | 2075 | if (is_int($code)) { |
2076 | 2076 | $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo); |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class CourseRestorer |
38 | 38 | { |
39 | - /** |
|
40 | - * The course-object |
|
41 | - */ |
|
39 | + /** |
|
40 | + * The course-object |
|
41 | + */ |
|
42 | 42 | public $course; |
43 | 43 | public $destination_course_info; |
44 | 44 | |
45 | - /** |
|
46 | - * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
47 | - * FILE_OVERWRITE) |
|
48 | - */ |
|
45 | + /** |
|
46 | + * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
47 | + * FILE_OVERWRITE) |
|
48 | + */ |
|
49 | 49 | public $file_option; |
50 | 50 | public $set_tools_invisible_by_default; |
51 | 51 | public $skip_content; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'events', |
58 | 58 | 'forum_category', |
59 | 59 | 'forums', |
60 | - // 'forum_topics', |
|
60 | + // 'forum_topics', |
|
61 | 61 | 'glossary', |
62 | 62 | 'quizzes', |
63 | 63 | 'test_category', |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | $this->tool_copy_settings = $array; |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Restore a course. |
|
129 | + /** |
|
130 | + * Restore a course. |
|
131 | 131 | * |
132 | - * @param string $destination_course_code code of the Chamilo-course in |
|
133 | - * @param int $session_id |
|
134 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
132 | + * @param string $destination_course_code code of the Chamilo-course in |
|
133 | + * @param int $session_id |
|
134 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
135 | 135 | * @param bool $respect_base_content |
136 | 136 | * @return bool |
137 | - */ |
|
137 | + */ |
|
138 | 138 | public function restore( |
139 | 139 | $destination_course_code = '', |
140 | 140 | $session_id = 0, |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - /** |
|
281 | - * Restore only harmless course settings: |
|
280 | + /** |
|
281 | + * Restore only harmless course settings: |
|
282 | 282 | * course_language, visibility, department_name,department_url, |
283 | 283 | * subscribe, unsubscribe ,category_code |
284 | - * |
|
285 | - * @param string $destination_course_code |
|
286 | - */ |
|
284 | + * |
|
285 | + * @param string $destination_course_code |
|
286 | + */ |
|
287 | 287 | public function restore_course_settings($destination_course_code) |
288 | 288 | { |
289 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
290 | - $course_info = $this->course->info; |
|
289 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
290 | + $course_info = $this->course->info; |
|
291 | 291 | $params['course_language'] = $course_info['language']; |
292 | 292 | $params['visibility'] = $course_info['visibility']; |
293 | 293 | $params['department_name'] = $course_info['department_name']; |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | $params['category_code'] = $course_info['categoryCode']; |
297 | 297 | $params['subscribe'] = $course_info['subscribe_allowed']; |
298 | 298 | $params['unsubscribe'] = $course_info['unsubscribe']; |
299 | - CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
300 | - } |
|
299 | + CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
300 | + } |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * Restore documents |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | $course_info = api_get_course_info($destination_course_code); |
312 | 312 | |
313 | 313 | if ($this->course->has_resources(RESOURCE_DOCUMENT)) { |
314 | - $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
315 | - $resources = $this->course->resources; |
|
314 | + $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
315 | + $resources = $this->course->resources; |
|
316 | 316 | $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
317 | 317 | |
318 | - foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
318 | + foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
319 | 319 | |
320 | 320 | if (empty($document->item_properties[0]['id_session'])) { |
321 | 321 | $my_session_id = 0; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
388 | - } elseif ($document->file_type == DOCUMENT) { |
|
388 | + } elseif ($document->file_type == DOCUMENT) { |
|
389 | 389 | //Checking if folder exists in the database otherwise we created it |
390 | 390 | $dir_to_create = dirname($document->path); |
391 | 391 | |
@@ -441,19 +441,19 @@ discard block |
||
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | - if (file_exists($path.$document->path)) { |
|
445 | - switch ($this->file_option) { |
|
446 | - case FILE_OVERWRITE: |
|
444 | + if (file_exists($path.$document->path)) { |
|
445 | + switch ($this->file_option) { |
|
446 | + case FILE_OVERWRITE: |
|
447 | 447 | $origin_path = $this->course->backup_path.'/'.$document->path; |
448 | 448 | |
449 | - if (file_exists($origin_path)) { |
|
450 | - copy($origin_path, $path.$document->path); |
|
449 | + if (file_exists($origin_path)) { |
|
450 | + copy($origin_path, $path.$document->path); |
|
451 | 451 | $sql = "SELECT id FROM $table |
452 | 452 | WHERE |
453 | 453 | c_id = ".$this->destination_course_id." AND |
454 | 454 | path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
455 | 455 | |
456 | - $res = Database::query($sql); |
|
456 | + $res = Database::query($sql); |
|
457 | 457 | $count = Database::num_rows($res); |
458 | 458 | |
459 | 459 | if ($count == 0) { |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | 'session_id' => $my_session_id, |
468 | 468 | ]; |
469 | 469 | |
470 | - $document_id = Database::insert($table, $params); |
|
470 | + $document_id = Database::insert($table, $params); |
|
471 | 471 | |
472 | 472 | if ($document_id) { |
473 | 473 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -575,83 +575,83 @@ discard block |
||
575 | 575 | ], |
576 | 576 | ] |
577 | 577 | ); |
578 | - } |
|
578 | + } |
|
579 | 579 | |
580 | - break; |
|
581 | - case FILE_SKIP: |
|
582 | - $sql = "SELECT id FROM $table |
|
580 | + break; |
|
581 | + case FILE_SKIP: |
|
582 | + $sql = "SELECT id FROM $table |
|
583 | 583 | WHERE |
584 | 584 | c_id = ".$this->destination_course_id." AND |
585 | 585 | path='/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
586 | - $res = Database::query($sql); |
|
587 | - $obj = Database::fetch_object($res); |
|
588 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
589 | - break; |
|
590 | - case FILE_RENAME: |
|
591 | - $i = 1; |
|
592 | - $ext = explode('.', basename($document->path)); |
|
593 | - if (count($ext) > 1) { |
|
594 | - $ext = array_pop($ext); |
|
595 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
596 | - $ext = '.'.$ext; |
|
597 | - } else { |
|
598 | - $ext = ''; |
|
599 | - $file_name_no_ext = $document->path; |
|
600 | - } |
|
601 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
602 | - $file_exists = file_exists($path.$new_file_name); |
|
603 | - while ($file_exists) { |
|
604 | - $i ++; |
|
605 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
606 | - $file_exists = file_exists($path.$new_file_name); |
|
607 | - } |
|
608 | - |
|
609 | - if (!empty($session_id)) { |
|
610 | - |
|
611 | - $document_path = explode('/',$document->path,3); |
|
612 | - $course_path = $path; |
|
613 | - $orig_base_folder = $document_path[1]; |
|
614 | - $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
615 | - |
|
616 | - if (is_dir($orig_base_path)) { |
|
617 | - |
|
618 | - $new_base_foldername = $orig_base_folder; |
|
619 | - $new_base_path = $orig_base_path; |
|
620 | - |
|
621 | - if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
622 | - unset($_SESSION['new_base_foldername']); |
|
623 | - unset($_SESSION['orig_base_foldername']); |
|
624 | - unset($_SESSION['new_base_path']); |
|
625 | - } |
|
626 | - |
|
627 | - $folder_exists = file_exists($new_base_path); |
|
628 | - if ($folder_exists) { |
|
629 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
630 | - $x = ''; |
|
631 | - while ($folder_exists) { |
|
632 | - $x = $x + 1; |
|
633 | - $new_base_foldername = $document_path[1].'_'.$x; |
|
634 | - $new_base_path = $orig_base_path.'_'.$x; |
|
586 | + $res = Database::query($sql); |
|
587 | + $obj = Database::fetch_object($res); |
|
588 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
589 | + break; |
|
590 | + case FILE_RENAME: |
|
591 | + $i = 1; |
|
592 | + $ext = explode('.', basename($document->path)); |
|
593 | + if (count($ext) > 1) { |
|
594 | + $ext = array_pop($ext); |
|
595 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
596 | + $ext = '.'.$ext; |
|
597 | + } else { |
|
598 | + $ext = ''; |
|
599 | + $file_name_no_ext = $document->path; |
|
600 | + } |
|
601 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
602 | + $file_exists = file_exists($path.$new_file_name); |
|
603 | + while ($file_exists) { |
|
604 | + $i ++; |
|
605 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
606 | + $file_exists = file_exists($path.$new_file_name); |
|
607 | + } |
|
608 | + |
|
609 | + if (!empty($session_id)) { |
|
610 | + |
|
611 | + $document_path = explode('/',$document->path,3); |
|
612 | + $course_path = $path; |
|
613 | + $orig_base_folder = $document_path[1]; |
|
614 | + $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
615 | + |
|
616 | + if (is_dir($orig_base_path)) { |
|
617 | + |
|
618 | + $new_base_foldername = $orig_base_folder; |
|
619 | + $new_base_path = $orig_base_path; |
|
620 | + |
|
621 | + if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
622 | + unset($_SESSION['new_base_foldername']); |
|
623 | + unset($_SESSION['orig_base_foldername']); |
|
624 | + unset($_SESSION['new_base_path']); |
|
625 | + } |
|
626 | + |
|
627 | + $folder_exists = file_exists($new_base_path); |
|
628 | + if ($folder_exists) { |
|
629 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
630 | + $x = ''; |
|
631 | + while ($folder_exists) { |
|
632 | + $x = $x + 1; |
|
633 | + $new_base_foldername = $document_path[1].'_'.$x; |
|
634 | + $new_base_path = $orig_base_path.'_'.$x; |
|
635 | 635 | if ($_SESSION['new_base_foldername'] == $new_base_foldername) { |
636 | 636 | break; |
637 | 637 | } |
638 | - $folder_exists = file_exists($new_base_path); |
|
639 | - } |
|
640 | - $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
641 | - $_SESSION['new_base_path'] = $new_base_path; |
|
642 | - } |
|
643 | - |
|
644 | - if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
645 | - $new_base_foldername = $_SESSION['new_base_foldername']; |
|
646 | - $new_base_path = $_SESSION['new_base_path']; |
|
647 | - } |
|
648 | - |
|
649 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
650 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
651 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
652 | - $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
653 | - |
|
654 | - copy_folder_course_session( |
|
638 | + $folder_exists = file_exists($new_base_path); |
|
639 | + } |
|
640 | + $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
641 | + $_SESSION['new_base_path'] = $new_base_path; |
|
642 | + } |
|
643 | + |
|
644 | + if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
645 | + $new_base_foldername = $_SESSION['new_base_foldername']; |
|
646 | + $new_base_path = $_SESSION['new_base_path']; |
|
647 | + } |
|
648 | + |
|
649 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
650 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
651 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
652 | + $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
653 | + |
|
654 | + copy_folder_course_session( |
|
655 | 655 | $basedir_dest_path, |
656 | 656 | $base_path_document, |
657 | 657 | $session_id, |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | 'session_id' => $my_session_id, |
694 | 694 | ]; |
695 | 695 | |
696 | - $document_id = Database::insert($table, $params); |
|
696 | + $document_id = Database::insert($table, $params); |
|
697 | 697 | |
698 | 698 | if ($document_id) { |
699 | 699 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -722,10 +722,10 @@ discard block |
||
722 | 722 | null, |
723 | 723 | $my_session_id |
724 | 724 | ); |
725 | - } else { |
|
726 | - if (file_exists($path.$document->path)) { |
|
725 | + } else { |
|
726 | + if (file_exists($path.$document->path)) { |
|
727 | 727 | copy($path.$document->path, $path.$new_file_name); |
728 | - } |
|
728 | + } |
|
729 | 729 | //Replace old course code with the new destination code see BT#1985 |
730 | 730 | if (file_exists($path.$new_file_name)) { |
731 | 731 | $file_info = pathinfo($path.$new_file_name); |
@@ -784,10 +784,10 @@ discard block |
||
784 | 784 | $my_session_id |
785 | 785 | ); |
786 | 786 | } |
787 | - } |
|
788 | - } else { |
|
787 | + } |
|
788 | + } else { |
|
789 | 789 | |
790 | - copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
790 | + copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
791 | 791 | |
792 | 792 | //Replace old course code with the new destination code see BT#1985 |
793 | 793 | if (file_exists($path.$new_file_name)) { |
@@ -847,20 +847,20 @@ discard block |
||
847 | 847 | null, |
848 | 848 | $my_session_id |
849 | 849 | ); |
850 | - } |
|
851 | - break; |
|
852 | - |
|
853 | - } // end switch |
|
854 | - } else { |
|
855 | - // end if file exists |
|
856 | - //make sure the source file actually exists |
|
857 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
850 | + } |
|
851 | + break; |
|
852 | + |
|
853 | + } // end switch |
|
854 | + } else { |
|
855 | + // end if file exists |
|
856 | + //make sure the source file actually exists |
|
857 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
858 | 858 | is_readable($this->course->backup_path.'/'.$document->path) && |
859 | 859 | is_dir(dirname($path.$document->path)) && |
860 | 860 | is_writeable(dirname($path.$document->path)) |
861 | 861 | ) { |
862 | - //echo 'Copying'; |
|
863 | - copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
862 | + //echo 'Copying'; |
|
863 | + copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
864 | 864 | |
865 | 865 | //Replace old course code with the new destination code see BT#1985 |
866 | 866 | if (file_exists($path.$document->path)) { |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | Database::query($sql); |
899 | 899 | } |
900 | 900 | |
901 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
901 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
902 | 902 | |
903 | 903 | $itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : ''; |
904 | 904 | $insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id(); |
@@ -920,79 +920,79 @@ discard block |
||
920 | 920 | null, |
921 | 921 | $my_session_id |
922 | 922 | ); |
923 | - } else { |
|
924 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
923 | + } else { |
|
924 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
925 | 925 | is_readable($this->course->backup_path.'/'.$document->path) |
926 | 926 | ) { |
927 | - error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
928 | - } |
|
929 | - if (!is_dir(dirname($path.$document->path))) { |
|
930 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
931 | - } |
|
932 | - if (!is_writeable(dirname($path.$document->path))) { |
|
933 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
934 | - } |
|
935 | - } |
|
936 | - } // end file doesn't exist |
|
937 | - } |
|
938 | - } // end for each |
|
939 | - |
|
940 | - // Delete sessions for the copy the new folder in session |
|
941 | - unset($_SESSION['new_base_foldername']); |
|
942 | - unset($_SESSION['orig_base_foldername']); |
|
943 | - unset($_SESSION['new_base_path']); |
|
944 | - } |
|
945 | - } |
|
946 | - |
|
947 | - /** |
|
948 | - * Restore scorm documents |
|
949 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
927 | + error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
928 | + } |
|
929 | + if (!is_dir(dirname($path.$document->path))) { |
|
930 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
931 | + } |
|
932 | + if (!is_writeable(dirname($path.$document->path))) { |
|
933 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
934 | + } |
|
935 | + } |
|
936 | + } // end file doesn't exist |
|
937 | + } |
|
938 | + } // end for each |
|
939 | + |
|
940 | + // Delete sessions for the copy the new folder in session |
|
941 | + unset($_SESSION['new_base_foldername']); |
|
942 | + unset($_SESSION['orig_base_foldername']); |
|
943 | + unset($_SESSION['new_base_path']); |
|
944 | + } |
|
945 | + } |
|
946 | + |
|
947 | + /** |
|
948 | + * Restore scorm documents |
|
949 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
950 | 950 | * see #7029 |
951 | - */ |
|
952 | - public function restore_scorm_documents() |
|
951 | + */ |
|
952 | + public function restore_scorm_documents() |
|
953 | 953 | { |
954 | - $perm = api_get_permissions_for_new_directories(); |
|
954 | + $perm = api_get_permissions_for_new_directories(); |
|
955 | 955 | |
956 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
957 | - $resources = $this->course->resources; |
|
956 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
957 | + $resources = $this->course->resources; |
|
958 | 958 | |
959 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
960 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
959 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
960 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
961 | 961 | |
962 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
962 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
963 | 963 | |
964 | - if (file_exists($path.$document->path)) { |
|
965 | - switch ($this->file_option) { |
|
966 | - case FILE_OVERWRITE: |
|
967 | - rmdirr($path.$document->path); |
|
964 | + if (file_exists($path.$document->path)) { |
|
965 | + switch ($this->file_option) { |
|
966 | + case FILE_OVERWRITE: |
|
967 | + rmdirr($path.$document->path); |
|
968 | 968 | copyDirTo( |
969 | 969 | $this->course->backup_path . '/' . $document->path, |
970 | 970 | $path . dirname($document->path), |
971 | 971 | false |
972 | 972 | ); |
973 | - break; |
|
974 | - case FILE_SKIP: |
|
975 | - break; |
|
973 | + break; |
|
974 | + case FILE_SKIP: |
|
975 | + break; |
|
976 | 976 | case FILE_RENAME: |
977 | - $i = 1; |
|
978 | - $ext = explode('.', basename($document->path)); |
|
979 | - if (count($ext) > 1) { |
|
980 | - $ext = array_pop($ext); |
|
981 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
982 | - $ext = '.'.$ext; |
|
983 | - } else { |
|
984 | - $ext = ''; |
|
985 | - $file_name_no_ext = $document->path; |
|
986 | - } |
|
987 | - |
|
988 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
989 | - $file_exists = file_exists($path.$new_file_name); |
|
990 | - |
|
991 | - while ($file_exists) { |
|
992 | - $i ++; |
|
993 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
994 | - $file_exists = file_exists($path.$new_file_name); |
|
995 | - } |
|
977 | + $i = 1; |
|
978 | + $ext = explode('.', basename($document->path)); |
|
979 | + if (count($ext) > 1) { |
|
980 | + $ext = array_pop($ext); |
|
981 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
982 | + $ext = '.'.$ext; |
|
983 | + } else { |
|
984 | + $ext = ''; |
|
985 | + $file_name_no_ext = $document->path; |
|
986 | + } |
|
987 | + |
|
988 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
989 | + $file_exists = file_exists($path.$new_file_name); |
|
990 | + |
|
991 | + while ($file_exists) { |
|
992 | + $i ++; |
|
993 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
994 | + $file_exists = file_exists($path.$new_file_name); |
|
995 | + } |
|
996 | 996 | |
997 | 997 | rename( |
998 | 998 | $this->course->backup_path . '/' . $document->path, |
@@ -1008,30 +1008,30 @@ discard block |
||
1008 | 1008 | $this->course->backup_path . '/' . $document->path |
1009 | 1009 | ); |
1010 | 1010 | |
1011 | - break; |
|
1012 | - } // end switch |
|
1013 | - } else { |
|
1011 | + break; |
|
1012 | + } // end switch |
|
1013 | + } else { |
|
1014 | 1014 | // end if file exists |
1015 | 1015 | copyDirTo( |
1016 | 1016 | $this->course->backup_path . '/' . $document->path, |
1017 | 1017 | $path . dirname($document->path), |
1018 | 1018 | false |
1019 | 1019 | ); |
1020 | - } |
|
1021 | - } // end for each |
|
1022 | - } |
|
1023 | - } |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * Restore forums |
|
1027 | - */ |
|
1028 | - public function restore_forums($sessionId = 0) |
|
1020 | + } |
|
1021 | + } // end for each |
|
1022 | + } |
|
1023 | + } |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * Restore forums |
|
1027 | + */ |
|
1028 | + public function restore_forums($sessionId = 0) |
|
1029 | 1029 | { |
1030 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1030 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1031 | 1031 | $sessionId = intval($sessionId); |
1032 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1033 | - $resources = $this->course->resources; |
|
1034 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1032 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1033 | + $resources = $this->course->resources; |
|
1034 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1035 | 1035 | $params = (array)$forum->obj; |
1036 | 1036 | $cat_id = ''; |
1037 | 1037 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1077,33 +1077,33 @@ discard block |
||
1077 | 1077 | Database::query($sql); |
1078 | 1078 | } |
1079 | 1079 | |
1080 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1081 | - |
|
1082 | - $forum_topics = 0; |
|
1083 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1084 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1085 | - if ($topic->obj->forum_id == $id) { |
|
1086 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1087 | - $forum_topics ++; |
|
1088 | - } |
|
1089 | - } |
|
1090 | - } |
|
1091 | - if ($forum_topics > 0) { |
|
1092 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1080 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1081 | + |
|
1082 | + $forum_topics = 0; |
|
1083 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1084 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1085 | + if ($topic->obj->forum_id == $id) { |
|
1086 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1087 | + $forum_topics ++; |
|
1088 | + } |
|
1089 | + } |
|
1090 | + } |
|
1091 | + if ($forum_topics > 0) { |
|
1092 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1093 | 1093 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
1094 | - Database::query($sql); |
|
1095 | - } |
|
1096 | - } |
|
1097 | - } |
|
1098 | - } |
|
1099 | - |
|
1100 | - /** |
|
1101 | - * Restore forum-categories |
|
1102 | - */ |
|
1094 | + Database::query($sql); |
|
1095 | + } |
|
1096 | + } |
|
1097 | + } |
|
1098 | + } |
|
1099 | + |
|
1100 | + /** |
|
1101 | + * Restore forum-categories |
|
1102 | + */ |
|
1103 | 1103 | public function restore_forum_category($my_id = null, $sessionId = 0) |
1104 | 1104 | { |
1105 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1106 | - $resources = $this->course->resources; |
|
1105 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1106 | + $resources = $this->course->resources; |
|
1107 | 1107 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
1108 | 1108 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
1109 | 1109 | if (!empty($my_id)) { |
@@ -1150,15 +1150,15 @@ discard block |
||
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | } |
1153 | - } |
|
1153 | + } |
|
1154 | 1154 | |
1155 | - /** |
|
1156 | - * Restore a forum-topic |
|
1157 | - */ |
|
1155 | + /** |
|
1156 | + * Restore a forum-topic |
|
1157 | + */ |
|
1158 | 1158 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1159 | 1159 | { |
1160 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1161 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1160 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1161 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1162 | 1162 | |
1163 | 1163 | $params = (array)$topic->obj; |
1164 | 1164 | $params = self::DBUTF8_array($params); |
@@ -1194,27 +1194,27 @@ discard block |
||
1194 | 1194 | $sessionId |
1195 | 1195 | ); |
1196 | 1196 | |
1197 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1197 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1198 | 1198 | |
1199 | - $topic_replies = -1; |
|
1199 | + $topic_replies = -1; |
|
1200 | 1200 | |
1201 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1202 | - if ($post->obj->thread_id == $thread_id) { |
|
1203 | - $topic_replies++; |
|
1204 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1205 | - } |
|
1206 | - } |
|
1207 | - return $new_id; |
|
1208 | - } |
|
1201 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1202 | + if ($post->obj->thread_id == $thread_id) { |
|
1203 | + $topic_replies++; |
|
1204 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1205 | + } |
|
1206 | + } |
|
1207 | + return $new_id; |
|
1208 | + } |
|
1209 | 1209 | |
1210 | - /** |
|
1211 | - * Restore a forum-post |
|
1212 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1213 | - */ |
|
1210 | + /** |
|
1211 | + * Restore a forum-post |
|
1212 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1213 | + */ |
|
1214 | 1214 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1215 | 1215 | { |
1216 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1217 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1216 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1217 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1218 | 1218 | $params = (array) $post->obj; |
1219 | 1219 | $params['c_id'] = $this->destination_course_id; |
1220 | 1220 | $params['forum_id'] = $forum_id; |
@@ -1249,37 +1249,37 @@ discard block |
||
1249 | 1249 | null, |
1250 | 1250 | $sessionId |
1251 | 1251 | ); |
1252 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1252 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1253 | 1253 | |
1254 | - return $new_id; |
|
1255 | - } |
|
1254 | + return $new_id; |
|
1255 | + } |
|
1256 | 1256 | |
1257 | - /** |
|
1258 | - * Restore links |
|
1259 | - */ |
|
1257 | + /** |
|
1258 | + * Restore links |
|
1259 | + */ |
|
1260 | 1260 | public function restore_links($session_id = 0) |
1261 | 1261 | { |
1262 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1263 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1264 | - $resources = $this->course->resources; |
|
1262 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1263 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1264 | + $resources = $this->course->resources; |
|
1265 | 1265 | |
1266 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1266 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1267 | 1267 | $cat_id = $this->restore_link_category( |
1268 | 1268 | $link->category_id, |
1269 | 1269 | $session_id |
1270 | 1270 | ); |
1271 | - $sql = "SELECT MAX(display_order) |
|
1271 | + $sql = "SELECT MAX(display_order) |
|
1272 | 1272 | FROM $link_table |
1273 | 1273 | WHERE |
1274 | 1274 | c_id = ".$this->destination_course_id." AND |
1275 | 1275 | category_id='" . intval($cat_id). "'"; |
1276 | - $result = Database::query($sql); |
|
1277 | - list($max_order) = Database::fetch_array($result); |
|
1276 | + $result = Database::query($sql); |
|
1277 | + list($max_order) = Database::fetch_array($result); |
|
1278 | 1278 | |
1279 | 1279 | $params = []; |
1280 | - if (!empty($session_id)) { |
|
1280 | + if (!empty($session_id)) { |
|
1281 | 1281 | $params['session_id'] = $session_id; |
1282 | - } |
|
1282 | + } |
|
1283 | 1283 | |
1284 | 1284 | $params['c_id'] = $this->destination_course_id; |
1285 | 1285 | $params['url'] = self::DBUTF8($link->url); |
@@ -1308,9 +1308,9 @@ discard block |
||
1308 | 1308 | } |
1309 | 1309 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1310 | 1310 | } |
1311 | - } |
|
1312 | - } |
|
1313 | - } |
|
1311 | + } |
|
1312 | + } |
|
1313 | + } |
|
1314 | 1314 | |
1315 | 1315 | /** |
1316 | 1316 | * Restore a link-category |
@@ -1354,21 +1354,21 @@ discard block |
||
1354 | 1354 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - /** |
|
1358 | - * Restore tool intro |
|
1359 | - */ |
|
1357 | + /** |
|
1358 | + * Restore tool intro |
|
1359 | + */ |
|
1360 | 1360 | public function restore_tool_intro($sessionId = 0) |
1361 | 1361 | { |
1362 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1362 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1363 | 1363 | $sessionId = intval($sessionId); |
1364 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1365 | - $resources = $this->course->resources; |
|
1366 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1367 | - $sql = "DELETE FROM ".$tool_intro_table." |
|
1364 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1365 | + $resources = $this->course->resources; |
|
1366 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1367 | + $sql = "DELETE FROM ".$tool_intro_table." |
|
1368 | 1368 | WHERE |
1369 | 1369 | c_id = ".$this->destination_course_id." AND |
1370 | 1370 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1371 | - Database::query($sql); |
|
1371 | + Database::query($sql); |
|
1372 | 1372 | |
1373 | 1373 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1374 | 1374 | $tool_intro->intro_text, |
@@ -1396,21 +1396,21 @@ discard block |
||
1396 | 1396 | |
1397 | 1397 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1398 | 1398 | } |
1399 | - } |
|
1400 | - } |
|
1401 | - } |
|
1399 | + } |
|
1400 | + } |
|
1401 | + } |
|
1402 | 1402 | |
1403 | - /** |
|
1404 | - * Restore events |
|
1405 | - */ |
|
1403 | + /** |
|
1404 | + * Restore events |
|
1405 | + */ |
|
1406 | 1406 | public function restore_events($sessionId = 0) |
1407 | 1407 | { |
1408 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1408 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1409 | 1409 | $sessionId = intval($sessionId); |
1410 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1411 | - $resources = $this->course->resources; |
|
1412 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1413 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1410 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1411 | + $resources = $this->course->resources; |
|
1412 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1413 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1414 | 1414 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1415 | 1415 | $event->content, |
1416 | 1416 | $this->course->code, |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | 'end_date' => $event->end_date, |
1429 | 1429 | 'session_id' => $sessionId, |
1430 | 1430 | ]; |
1431 | - $new_event_id = Database::insert($table, $params); |
|
1431 | + $new_event_id = Database::insert($table, $params); |
|
1432 | 1432 | |
1433 | 1433 | if ($new_event_id) { |
1434 | 1434 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1441,30 +1441,30 @@ discard block |
||
1441 | 1441 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1442 | 1442 | } |
1443 | 1443 | |
1444 | - // Copy event attachment |
|
1444 | + // Copy event attachment |
|
1445 | 1445 | |
1446 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1447 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1446 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1447 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1448 | 1448 | |
1449 | - if (!empty($this->course->orig)) { |
|
1449 | + if (!empty($this->course->orig)) { |
|
1450 | 1450 | |
1451 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1452 | - $sql = 'SELECT path, comment, size, filename |
|
1451 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1452 | + $sql = 'SELECT path, comment, size, filename |
|
1453 | 1453 | FROM '.$table_attachment.' |
1454 | 1454 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1455 | - $attachment_event = Database::query($sql); |
|
1456 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1455 | + $attachment_event = Database::query($sql); |
|
1456 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1457 | 1457 | |
1458 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1458 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1459 | 1459 | !is_dir($origin_path.$attachment_event->path) |
1460 | 1460 | ) { |
1461 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1462 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1463 | - //$copy_result = true; |
|
1464 | - if ($copy_result) { |
|
1465 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1461 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1462 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1463 | + //$copy_result = true; |
|
1464 | + if ($copy_result) { |
|
1465 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1466 | 1466 | |
1467 | - $params = [ |
|
1467 | + $params = [ |
|
1468 | 1468 | 'c_id' => $this->destination_course_id, |
1469 | 1469 | 'path' => self::DBUTF8($new_filename), |
1470 | 1470 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1478,17 +1478,17 @@ discard block |
||
1478 | 1478 | Database::query($sql); |
1479 | 1479 | } |
1480 | 1480 | } |
1481 | - } |
|
1482 | - } else { |
|
1483 | - // get the info of the file |
|
1484 | - if (!empty($event->attachment_path) && |
|
1481 | + } |
|
1482 | + } else { |
|
1483 | + // get the info of the file |
|
1484 | + if (!empty($event->attachment_path) && |
|
1485 | 1485 | is_file($origin_path.$event->attachment_path) && |
1486 | 1486 | is_readable($origin_path.$event->attachment_path) |
1487 | 1487 | ) { |
1488 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1489 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1490 | - if ($copy_result) { |
|
1491 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1488 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1489 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1490 | + if ($copy_result) { |
|
1491 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1492 | 1492 | |
1493 | 1493 | $params = [ |
1494 | 1494 | 'c_id' => $this->destination_course_id, |
@@ -1504,29 +1504,29 @@ discard block |
||
1504 | 1504 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1505 | 1505 | Database::query($sql); |
1506 | 1506 | } |
1507 | - } |
|
1508 | - } |
|
1509 | - } |
|
1510 | - } |
|
1511 | - } |
|
1512 | - } |
|
1513 | - |
|
1514 | - /** |
|
1515 | - * Restore course-description |
|
1516 | - */ |
|
1507 | + } |
|
1508 | + } |
|
1509 | + } |
|
1510 | + } |
|
1511 | + } |
|
1512 | + } |
|
1513 | + |
|
1514 | + /** |
|
1515 | + * Restore course-description |
|
1516 | + */ |
|
1517 | 1517 | public function restore_course_descriptions($session_id = 0) |
1518 | 1518 | { |
1519 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1520 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1521 | - $resources = $this->course->resources; |
|
1522 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1519 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1520 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1521 | + $resources = $this->course->resources; |
|
1522 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1523 | 1523 | $courseDescription = (array) $cd; |
1524 | 1524 | |
1525 | 1525 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
1526 | 1526 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
1527 | 1527 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
1528 | 1528 | |
1529 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1529 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1530 | 1530 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1531 | 1531 | $content, |
1532 | 1532 | $this->course->code, |
@@ -1554,22 +1554,22 @@ discard block |
||
1554 | 1554 | } |
1555 | 1555 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1556 | 1556 | } |
1557 | - } |
|
1558 | - } |
|
1559 | - } |
|
1557 | + } |
|
1558 | + } |
|
1559 | + } |
|
1560 | 1560 | |
1561 | - /** |
|
1562 | - * Restore announcements |
|
1563 | - */ |
|
1561 | + /** |
|
1562 | + * Restore announcements |
|
1563 | + */ |
|
1564 | 1564 | public function restore_announcements($sessionId = 0) |
1565 | 1565 | { |
1566 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1566 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1567 | 1567 | $sessionId = intval($sessionId); |
1568 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1569 | - $resources = $this->course->resources; |
|
1570 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1568 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1569 | + $resources = $this->course->resources; |
|
1570 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1571 | 1571 | |
1572 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1572 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1573 | 1573 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1574 | 1574 | $announcement->content, |
1575 | 1575 | $this->course->code, |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | 'session_id' => $sessionId, |
1589 | 1589 | ]; |
1590 | 1590 | |
1591 | - $new_announcement_id = Database::insert($table, $params); |
|
1591 | + $new_announcement_id = Database::insert($table, $params); |
|
1592 | 1592 | |
1593 | 1593 | if ($new_announcement_id) { |
1594 | 1594 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1600,32 +1600,32 @@ discard block |
||
1600 | 1600 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1601 | 1601 | } |
1602 | 1602 | |
1603 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1604 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1603 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1604 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1605 | 1605 | |
1606 | - // Copy announcement attachment file |
|
1607 | - if (!empty($this->course->orig)) { |
|
1606 | + // Copy announcement attachment file |
|
1607 | + if (!empty($this->course->orig)) { |
|
1608 | 1608 | |
1609 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1610 | - $sql = 'SELECT path, comment, size, filename |
|
1609 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1610 | + $sql = 'SELECT path, comment, size, filename |
|
1611 | 1611 | FROM '.$table_attachment.' |
1612 | 1612 | WHERE |
1613 | 1613 | c_id = '.$this->destination_course_id.' AND |
1614 | 1614 | announcement_id = '.$id; |
1615 | - $attachment_event = Database::query($sql); |
|
1616 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1615 | + $attachment_event = Database::query($sql); |
|
1616 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1617 | 1617 | |
1618 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1618 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1619 | 1619 | !is_dir($origin_path.$attachment_event->path) |
1620 | 1620 | ) { |
1621 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1621 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1622 | 1622 | $copy_result = copy( |
1623 | 1623 | $origin_path.$attachment_event->path, |
1624 | 1624 | $destination_path.$new_filename |
1625 | 1625 | ); |
1626 | 1626 | |
1627 | - if ($copy_result) { |
|
1628 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1627 | + if ($copy_result) { |
|
1628 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1629 | 1629 | |
1630 | 1630 | $params = [ |
1631 | 1631 | 'c_id' => $this->destination_course_id, |
@@ -1642,20 +1642,20 @@ discard block |
||
1642 | 1642 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1643 | 1643 | Database::query($sql); |
1644 | 1644 | } |
1645 | - } |
|
1646 | - } |
|
1647 | - } else { |
|
1648 | - // get the info of the file |
|
1649 | - if (!empty($announcement->attachment_path) && |
|
1645 | + } |
|
1646 | + } |
|
1647 | + } else { |
|
1648 | + // get the info of the file |
|
1649 | + if (!empty($announcement->attachment_path) && |
|
1650 | 1650 | is_file($origin_path.$announcement->attachment_path) && |
1651 | 1651 | is_readable($origin_path.$announcement->attachment_path) |
1652 | 1652 | ) { |
1653 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1654 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1653 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1654 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1655 | 1655 | |
1656 | - if ($copy_result) { |
|
1657 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1658 | - /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1656 | + if ($copy_result) { |
|
1657 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1658 | + /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1659 | 1659 | c_id = ".$this->destination_course_id." , |
1660 | 1660 | path = '".self::DBUTF8escapestring($new_filename)."', |
1661 | 1661 | comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."', |
@@ -1678,12 +1678,12 @@ discard block |
||
1678 | 1678 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1679 | 1679 | Database::query($sql); |
1680 | 1680 | } |
1681 | - } |
|
1682 | - } |
|
1683 | - } |
|
1684 | - } |
|
1685 | - } |
|
1686 | - } |
|
1681 | + } |
|
1682 | + } |
|
1683 | + } |
|
1684 | + } |
|
1685 | + } |
|
1686 | + } |
|
1687 | 1687 | |
1688 | 1688 | /** |
1689 | 1689 | * Restore Quiz |
@@ -1694,13 +1694,13 @@ discard block |
||
1694 | 1694 | $session_id = 0, |
1695 | 1695 | $respect_base_content = false |
1696 | 1696 | ) { |
1697 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1698 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1699 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1700 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1701 | - $resources = $this->course->resources; |
|
1697 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1698 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1699 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1700 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1701 | + $resources = $this->course->resources; |
|
1702 | 1702 | |
1703 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1703 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1704 | 1704 | |
1705 | 1705 | if (isset($quiz->obj)) { |
1706 | 1706 | //For new imports |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | $quiz->obj = $quiz; |
1711 | 1711 | } |
1712 | 1712 | |
1713 | - $doc = ''; |
|
1713 | + $doc = ''; |
|
1714 | 1714 | if (!empty($quiz->sound)) { |
1715 | 1715 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1716 | 1716 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1718,14 +1718,14 @@ discard block |
||
1718 | 1718 | WHERE |
1719 | 1719 | c_id = " . $this->destination_course_id . " AND |
1720 | 1720 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1721 | - $doc = Database::query($sql); |
|
1722 | - $doc = Database::fetch_object($doc); |
|
1723 | - $doc = str_replace('/audio/', '', $doc->path); |
|
1724 | - } |
|
1725 | - } |
|
1726 | - |
|
1727 | - if ($id != -1) { |
|
1728 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1721 | + $doc = Database::query($sql); |
|
1722 | + $doc = Database::fetch_object($doc); |
|
1723 | + $doc = str_replace('/audio/', '', $doc->path); |
|
1724 | + } |
|
1725 | + } |
|
1726 | + |
|
1727 | + if ($id != -1) { |
|
1728 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1729 | 1729 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1730 | 1730 | $quiz->description, |
1731 | 1731 | $this->course->code, |
@@ -1734,13 +1734,13 @@ discard block |
||
1734 | 1734 | $this->course->info['path'] |
1735 | 1735 | ); |
1736 | 1736 | |
1737 | - global $_custom; |
|
1738 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1737 | + global $_custom; |
|
1738 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1739 | 1739 | $_custom['exercises_clean_dates_when_restoring'] |
1740 | 1740 | ) { |
1741 | - $quiz->start_time = null; |
|
1742 | - $quiz->end_time = null; |
|
1743 | - } |
|
1741 | + $quiz->start_time = null; |
|
1742 | + $quiz->end_time = null; |
|
1743 | + } |
|
1744 | 1744 | |
1745 | 1745 | $params = array( |
1746 | 1746 | 'c_id' => $this->destination_course_id, |
@@ -1772,10 +1772,10 @@ discard block |
||
1772 | 1772 | } |
1773 | 1773 | $params['session_id'] = $my_session_id; |
1774 | 1774 | } else { |
1775 | - if (!empty($session_id)) { |
|
1776 | - $session_id = intval($session_id); |
|
1775 | + if (!empty($session_id)) { |
|
1776 | + $session_id = intval($session_id); |
|
1777 | 1777 | $params['session_id'] = $session_id; |
1778 | - } |
|
1778 | + } |
|
1779 | 1779 | } |
1780 | 1780 | $new_id = Database::insert($table_qui, $params); |
1781 | 1781 | |
@@ -1784,15 +1784,15 @@ discard block |
||
1784 | 1784 | Database::query($sql); |
1785 | 1785 | } |
1786 | 1786 | |
1787 | - } else { |
|
1788 | - // $id = -1 identifies the fictionary test for collecting |
|
1789 | - // orphan questions. We do not store it in the database. |
|
1790 | - $new_id = -1; |
|
1791 | - } |
|
1787 | + } else { |
|
1788 | + // $id = -1 identifies the fictionary test for collecting |
|
1789 | + // orphan questions. We do not store it in the database. |
|
1790 | + $new_id = -1; |
|
1791 | + } |
|
1792 | 1792 | |
1793 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1793 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1794 | 1794 | |
1795 | - $order = 0; |
|
1795 | + $order = 0; |
|
1796 | 1796 | if (!empty($quiz->question_ids)) { |
1797 | 1797 | foreach ($quiz->question_ids as $index => $question_id) { |
1798 | 1798 | $qid = $this->restore_quiz_question($question_id); |
@@ -1805,30 +1805,30 @@ discard block |
||
1805 | 1805 | Database::query($sql); |
1806 | 1806 | } |
1807 | 1807 | } |
1808 | - } |
|
1809 | - } |
|
1810 | - } |
|
1808 | + } |
|
1809 | + } |
|
1810 | + } |
|
1811 | 1811 | |
1812 | - /** |
|
1813 | - * Restore quiz-questions |
|
1812 | + /** |
|
1813 | + * Restore quiz-questions |
|
1814 | 1814 | * @params int question id |
1815 | - */ |
|
1815 | + */ |
|
1816 | 1816 | public function restore_quiz_question($id) |
1817 | 1817 | { |
1818 | - $resources = $this->course->resources; |
|
1818 | + $resources = $this->course->resources; |
|
1819 | 1819 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1820 | 1820 | |
1821 | - $new_id = 0; |
|
1821 | + $new_id = 0; |
|
1822 | 1822 | |
1823 | - if (is_object($question)) { |
|
1824 | - if ($question->is_restored()) { |
|
1825 | - return $question->destination_id; |
|
1826 | - } |
|
1827 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1828 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1823 | + if (is_object($question)) { |
|
1824 | + if ($question->is_restored()) { |
|
1825 | + return $question->destination_id; |
|
1826 | + } |
|
1827 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1828 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1829 | 1829 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1830 | 1830 | |
1831 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1831 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1832 | 1832 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1833 | 1833 | $question->description, |
1834 | 1834 | $this->course->code, |
@@ -1849,7 +1849,7 @@ discard block |
||
1849 | 1849 | 'extra' => self::DBUTF8($question->extra), |
1850 | 1850 | ]; |
1851 | 1851 | |
1852 | - $new_id = Database::insert($table_que, $params); |
|
1852 | + $new_id = Database::insert($table_que, $params); |
|
1853 | 1853 | |
1854 | 1854 | if ($new_id) { |
1855 | 1855 | |
@@ -1890,7 +1890,7 @@ discard block |
||
1890 | 1890 | |
1891 | 1891 | foreach ($temp as $index => $answer) { |
1892 | 1892 | //id = '".$index."', |
1893 | - $params = [ |
|
1893 | + $params = [ |
|
1894 | 1894 | 'c_id' => $this->destination_course_id, |
1895 | 1895 | 'question_id' => $new_id, |
1896 | 1896 | 'answer' => self::DBUTF8($answer['answer']), |
@@ -1907,12 +1907,12 @@ discard block |
||
1907 | 1907 | $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId"; |
1908 | 1908 | Database::query($sql); |
1909 | 1909 | } |
1910 | - } |
|
1911 | - } else { |
|
1910 | + } |
|
1911 | + } else { |
|
1912 | 1912 | $correct_answers = array(); |
1913 | - foreach ($question->answers as $index => $answer) { |
|
1913 | + foreach ($question->answers as $index => $answer) { |
|
1914 | 1914 | |
1915 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1915 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1916 | 1916 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1917 | 1917 | $answer['answer'], |
1918 | 1918 | $this->course->code, |
@@ -1951,8 +1951,8 @@ discard block |
||
1951 | 1951 | } |
1952 | 1952 | |
1953 | 1953 | $correct_answers[$answerId] = $answer['correct']; |
1954 | - } |
|
1955 | - } |
|
1954 | + } |
|
1955 | + } |
|
1956 | 1956 | |
1957 | 1957 | //Current course id |
1958 | 1958 | $course_id = api_get_course_int_id(); |
@@ -2049,12 +2049,12 @@ discard block |
||
2049 | 2049 | } |
2050 | 2050 | } |
2051 | 2051 | } |
2052 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2053 | - } |
|
2054 | - return $new_id; |
|
2055 | - } |
|
2052 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2053 | + } |
|
2054 | + return $new_id; |
|
2055 | + } |
|
2056 | 2056 | |
2057 | - /** |
|
2057 | + /** |
|
2058 | 2058 | * @todo : add session id when used for session |
2059 | 2059 | */ |
2060 | 2060 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2134,21 +2134,21 @@ discard block |
||
2134 | 2134 | $sessionId = intval($sessionId); |
2135 | 2135 | |
2136 | 2136 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2137 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2138 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2139 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2140 | - $resources = $this->course->resources; |
|
2141 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2137 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2138 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2139 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2140 | + $resources = $this->course->resources; |
|
2141 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2142 | 2142 | |
2143 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2143 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2144 | 2144 | WHERE |
2145 | 2145 | c_id = '.$this->destination_course_id.' AND |
2146 | 2146 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2147 | 2147 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2148 | 2148 | |
2149 | - $result_check = Database::query($sql); |
|
2149 | + $result_check = Database::query($sql); |
|
2150 | 2150 | |
2151 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2151 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2152 | 2152 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2153 | 2153 | $survey->title, |
2154 | 2154 | $this->course->code, |
@@ -2202,20 +2202,20 @@ discard block |
||
2202 | 2202 | 'session_id' => $sessionId, |
2203 | 2203 | ]; |
2204 | 2204 | |
2205 | - //An existing survey exists with the same code and the same language |
|
2206 | - if (Database::num_rows($result_check) == 1) { |
|
2207 | - switch ($this->file_option) { |
|
2208 | - case FILE_SKIP: |
|
2209 | - //Do nothing |
|
2210 | - break; |
|
2211 | - case FILE_RENAME: |
|
2212 | - $survey_code = $survey->code.'_'; |
|
2213 | - $i=1; |
|
2214 | - $temp_survey_code = $survey_code.$i; |
|
2215 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2216 | - $temp_survey_code = $survey_code.++$i; |
|
2217 | - } |
|
2218 | - $survey_code = $temp_survey_code; |
|
2205 | + //An existing survey exists with the same code and the same language |
|
2206 | + if (Database::num_rows($result_check) == 1) { |
|
2207 | + switch ($this->file_option) { |
|
2208 | + case FILE_SKIP: |
|
2209 | + //Do nothing |
|
2210 | + break; |
|
2211 | + case FILE_RENAME: |
|
2212 | + $survey_code = $survey->code.'_'; |
|
2213 | + $i=1; |
|
2214 | + $temp_survey_code = $survey_code.$i; |
|
2215 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2216 | + $temp_survey_code = $survey_code.++$i; |
|
2217 | + } |
|
2218 | + $survey_code = $temp_survey_code; |
|
2219 | 2219 | |
2220 | 2220 | $params['code'] = $survey_code; |
2221 | 2221 | $new_id = Database::insert($table_sur, $params); |
@@ -2234,25 +2234,25 @@ discard block |
||
2234 | 2234 | Database::query($sql); |
2235 | 2235 | } |
2236 | 2236 | } |
2237 | - break; |
|
2238 | - case FILE_OVERWRITE: |
|
2239 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2240 | - // getting the information of the survey (used for when the survey is shared) |
|
2237 | + break; |
|
2238 | + case FILE_OVERWRITE: |
|
2239 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2240 | + // getting the information of the survey (used for when the survey is shared) |
|
2241 | 2241 | |
2242 | - $sql = "SELECT * FROM $table_sur |
|
2242 | + $sql = "SELECT * FROM $table_sur |
|
2243 | 2243 | WHERE |
2244 | 2244 | c_id = ".$this->destination_course_id." AND |
2245 | 2245 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2246 | - $result = Database::query($sql); |
|
2247 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2246 | + $result = Database::query($sql); |
|
2247 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2248 | 2248 | |
2249 | - // if the survey is shared => also delete the shared content |
|
2250 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2249 | + // if the survey is shared => also delete the shared content |
|
2250 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2251 | 2251 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2252 | - } |
|
2253 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2252 | + } |
|
2253 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2254 | 2254 | |
2255 | - // Insert the new source survey |
|
2255 | + // Insert the new source survey |
|
2256 | 2256 | $new_id = Database::insert($table_sur, $params); |
2257 | 2257 | |
2258 | 2258 | if ($new_id) { |
@@ -2273,11 +2273,11 @@ discard block |
||
2273 | 2273 | Database::query($sql); |
2274 | 2274 | } |
2275 | 2275 | } |
2276 | - break; |
|
2277 | - default: |
|
2278 | - break; |
|
2279 | - } |
|
2280 | - } else { |
|
2276 | + break; |
|
2277 | + default: |
|
2278 | + break; |
|
2279 | + } |
|
2280 | + } else { |
|
2281 | 2281 | // No existing survey with the same language and the same code, we just copy the survey |
2282 | 2282 | $new_id = Database::insert($table_sur, $params); |
2283 | 2283 | |
@@ -2299,43 +2299,43 @@ discard block |
||
2299 | 2299 | Database::query($sql); |
2300 | 2300 | } |
2301 | 2301 | } |
2302 | - } |
|
2303 | - } |
|
2304 | - } |
|
2305 | - } |
|
2306 | - |
|
2307 | - /** |
|
2308 | - * Check availability of a survey code |
|
2309 | - */ |
|
2302 | + } |
|
2303 | + } |
|
2304 | + } |
|
2305 | + } |
|
2306 | + |
|
2307 | + /** |
|
2308 | + * Check availability of a survey code |
|
2309 | + */ |
|
2310 | 2310 | public function is_survey_code_available($survey_code) |
2311 | 2311 | { |
2312 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2313 | - $sql = "SELECT * FROM $table_sur |
|
2312 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2313 | + $sql = "SELECT * FROM $table_sur |
|
2314 | 2314 | WHERE |
2315 | 2315 | c_id = ".$this->destination_course_id." AND |
2316 | 2316 | code='".self::DBUTF8escapestring($survey_code)."'"; |
2317 | - $result = Database::query($sql); |
|
2318 | - if (Database::num_rows($result) > 0) return false; else return true; |
|
2319 | - } |
|
2317 | + $result = Database::query($sql); |
|
2318 | + if (Database::num_rows($result) > 0) return false; else return true; |
|
2319 | + } |
|
2320 | 2320 | |
2321 | - /** |
|
2322 | - * Restore survey-questions |
|
2323 | - */ |
|
2321 | + /** |
|
2322 | + * Restore survey-questions |
|
2323 | + */ |
|
2324 | 2324 | public function restore_survey_question($id, $survey_id) |
2325 | 2325 | { |
2326 | - $resources = $this->course->resources; |
|
2327 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2326 | + $resources = $this->course->resources; |
|
2327 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2328 | 2328 | |
2329 | - $new_id=0; |
|
2329 | + $new_id=0; |
|
2330 | 2330 | |
2331 | - if (is_object($question)) { |
|
2332 | - if ($question->is_restored()) { |
|
2333 | - return $question->destination_id; |
|
2334 | - } |
|
2335 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2336 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2331 | + if (is_object($question)) { |
|
2332 | + if ($question->is_restored()) { |
|
2333 | + return $question->destination_id; |
|
2334 | + } |
|
2335 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2336 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2337 | 2337 | |
2338 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2338 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2339 | 2339 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2340 | 2340 | $question->survey_question, |
2341 | 2341 | $this->course->code, |
@@ -2389,10 +2389,10 @@ discard block |
||
2389 | 2389 | } |
2390 | 2390 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2391 | 2391 | } |
2392 | - } |
|
2392 | + } |
|
2393 | 2393 | |
2394 | - return $new_id; |
|
2395 | - } |
|
2394 | + return $new_id; |
|
2395 | + } |
|
2396 | 2396 | |
2397 | 2397 | /** |
2398 | 2398 | * Restoring learning paths |
@@ -2403,20 +2403,20 @@ discard block |
||
2403 | 2403 | { |
2404 | 2404 | $session_id = intval($session_id); |
2405 | 2405 | |
2406 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2406 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2407 | 2407 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2408 | 2408 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2409 | 2409 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2410 | 2410 | |
2411 | - $resources = $this->course->resources; |
|
2411 | + $resources = $this->course->resources; |
|
2412 | 2412 | |
2413 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2414 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2413 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2414 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2415 | 2415 | |
2416 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2416 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2417 | 2417 | |
2418 | - $condition_session = ""; |
|
2419 | - if (!empty($session_id)) { |
|
2418 | + $condition_session = ""; |
|
2419 | + if (!empty($session_id)) { |
|
2420 | 2420 | if ($respect_base_content) { |
2421 | 2421 | $my_session_id = $lp->session_id; |
2422 | 2422 | if (!empty($lp->session_id)) { |
@@ -2427,21 +2427,21 @@ discard block |
||
2427 | 2427 | $session_id = intval($session_id); |
2428 | 2428 | $condition_session = $session_id; |
2429 | 2429 | } |
2430 | - } |
|
2431 | - |
|
2432 | - // Adding the author's image |
|
2433 | - if (!empty($lp->preview_image)) { |
|
2434 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2435 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2436 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2437 | - //$copy_result = true; |
|
2438 | - if ($copy_result) { |
|
2439 | - $lp->preview_image = $new_filename; |
|
2440 | - } else { |
|
2441 | - $lp->preview_image =''; |
|
2442 | - } |
|
2443 | - } |
|
2444 | - } |
|
2430 | + } |
|
2431 | + |
|
2432 | + // Adding the author's image |
|
2433 | + if (!empty($lp->preview_image)) { |
|
2434 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2435 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2436 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2437 | + //$copy_result = true; |
|
2438 | + if ($copy_result) { |
|
2439 | + $lp->preview_image = $new_filename; |
|
2440 | + } else { |
|
2441 | + $lp->preview_image =''; |
|
2442 | + } |
|
2443 | + } |
|
2444 | + } |
|
2445 | 2445 | |
2446 | 2446 | if ($this->add_text_in_items) { |
2447 | 2447 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2488,7 +2488,7 @@ discard block |
||
2488 | 2488 | $params['session_id'] = $condition_session; |
2489 | 2489 | } |
2490 | 2490 | |
2491 | - $new_lp_id = Database::insert($table_main, $params); |
|
2491 | + $new_lp_id = Database::insert($table_main, $params); |
|
2492 | 2492 | |
2493 | 2493 | if ($new_lp_id) { |
2494 | 2494 | |
@@ -2549,13 +2549,13 @@ discard block |
||
2549 | 2549 | $old_refs = array(); |
2550 | 2550 | $prerequisite_ids = array(); |
2551 | 2551 | |
2552 | - foreach ($lp->get_items() as $index => $item) { |
|
2553 | - // we set the ref code here and then we update in a for loop |
|
2554 | - $ref = $item['ref']; |
|
2552 | + foreach ($lp->get_items() as $index => $item) { |
|
2553 | + // we set the ref code here and then we update in a for loop |
|
2554 | + $ref = $item['ref']; |
|
2555 | 2555 | |
2556 | - // Dealing with path the same way as ref as some data has |
|
2556 | + // Dealing with path the same way as ref as some data has |
|
2557 | 2557 | // been put into path when it's a local resource |
2558 | - // Only fix the path for no scos |
|
2558 | + // Only fix the path for no scos |
|
2559 | 2559 | if ($item['item_type'] == 'sco') { |
2560 | 2560 | $path = $item['path']; |
2561 | 2561 | } else { |
@@ -2584,128 +2584,128 @@ discard block |
||
2584 | 2584 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2585 | 2585 | ]; |
2586 | 2586 | |
2587 | - $new_item_id = Database::insert($table_item, $params); |
|
2587 | + $new_item_id = Database::insert($table_item, $params); |
|
2588 | 2588 | |
2589 | 2589 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2590 | 2590 | Database::query($sql); |
2591 | 2591 | |
2592 | - //save a link between old and new item IDs |
|
2593 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2594 | - //save a reference of items that need a parent_item_id refresh |
|
2595 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2596 | - //save a reference of items that need a previous_item_id refresh |
|
2597 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2598 | - //save a reference of items that need a next_item_id refresh |
|
2599 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2600 | - |
|
2601 | - if (!empty($item['prerequisite'])) { |
|
2602 | - if ($lp->lp_type =='2') { |
|
2603 | - // if is an sco |
|
2604 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2605 | - } else { |
|
2606 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2607 | - } |
|
2608 | - } |
|
2609 | - |
|
2610 | - if (!empty($ref)) { |
|
2611 | - if ($lp->lp_type =='2') { |
|
2612 | - // if is an sco |
|
2613 | - $old_refs[$new_item_id]= $ref; |
|
2614 | - } else { |
|
2592 | + //save a link between old and new item IDs |
|
2593 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2594 | + //save a reference of items that need a parent_item_id refresh |
|
2595 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2596 | + //save a reference of items that need a previous_item_id refresh |
|
2597 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2598 | + //save a reference of items that need a next_item_id refresh |
|
2599 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2600 | + |
|
2601 | + if (!empty($item['prerequisite'])) { |
|
2602 | + if ($lp->lp_type =='2') { |
|
2603 | + // if is an sco |
|
2604 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2605 | + } else { |
|
2606 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2607 | + } |
|
2608 | + } |
|
2609 | + |
|
2610 | + if (!empty($ref)) { |
|
2611 | + if ($lp->lp_type =='2') { |
|
2612 | + // if is an sco |
|
2613 | + $old_refs[$new_item_id]= $ref; |
|
2614 | + } else { |
|
2615 | 2615 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2616 | - } |
|
2617 | - } |
|
2616 | + } |
|
2617 | + } |
|
2618 | 2618 | |
2619 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2620 | - } |
|
2619 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2620 | + } |
|
2621 | 2621 | |
2622 | - // Updating prerequisites |
|
2623 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2624 | - if($my_old_prerequisite != ''){ |
|
2625 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2622 | + // Updating prerequisites |
|
2623 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2624 | + if($my_old_prerequisite != ''){ |
|
2625 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2626 | 2626 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2627 | - Database::query($sql); |
|
2628 | - } |
|
2629 | - } |
|
2630 | - |
|
2631 | - // Updating refs |
|
2632 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2633 | - if ($my_old_ref != '') { |
|
2634 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2627 | + Database::query($sql); |
|
2628 | + } |
|
2629 | + } |
|
2630 | + |
|
2631 | + // Updating refs |
|
2632 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2633 | + if ($my_old_ref != '') { |
|
2634 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2635 | 2635 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2636 | - Database::query($sql); |
|
2637 | - } |
|
2638 | - } |
|
2639 | - |
|
2640 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2641 | - $parent_new_id = 0; |
|
2642 | - if($parent_item_old_id != 0){ |
|
2643 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2644 | - } |
|
2645 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2636 | + Database::query($sql); |
|
2637 | + } |
|
2638 | + } |
|
2639 | + |
|
2640 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2641 | + $parent_new_id = 0; |
|
2642 | + if($parent_item_old_id != 0){ |
|
2643 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2644 | + } |
|
2645 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2646 | 2646 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2647 | - Database::query($sql); |
|
2648 | - } |
|
2649 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2650 | - $previous_new_id = 0; |
|
2651 | - if($previous_item_old_id != 0){ |
|
2652 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2653 | - } |
|
2654 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2647 | + Database::query($sql); |
|
2648 | + } |
|
2649 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2650 | + $previous_new_id = 0; |
|
2651 | + if($previous_item_old_id != 0){ |
|
2652 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2653 | + } |
|
2654 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2655 | 2655 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2656 | - Database::query($sql); |
|
2657 | - } |
|
2658 | - |
|
2659 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2660 | - $next_new_id = 0; |
|
2661 | - if($next_item_old_id != 0){ |
|
2662 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2663 | - } |
|
2664 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2656 | + Database::query($sql); |
|
2657 | + } |
|
2658 | + |
|
2659 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2660 | + $next_new_id = 0; |
|
2661 | + if($next_item_old_id != 0){ |
|
2662 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2663 | + } |
|
2664 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2665 | 2665 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2666 | - Database::query($sql); |
|
2667 | - } |
|
2668 | - |
|
2669 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2670 | - $prerequisite_new_id = 0; |
|
2671 | - if($prerequisite_old_id != 0){ |
|
2672 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2673 | - } |
|
2674 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2666 | + Database::query($sql); |
|
2667 | + } |
|
2668 | + |
|
2669 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2670 | + $prerequisite_new_id = 0; |
|
2671 | + if($prerequisite_old_id != 0){ |
|
2672 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2673 | + } |
|
2674 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2675 | 2675 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2676 | - Database::query($sql); |
|
2677 | - } |
|
2678 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2679 | - } |
|
2680 | - } |
|
2681 | - } |
|
2682 | - |
|
2683 | - /** |
|
2684 | - * Restore works |
|
2676 | + Database::query($sql); |
|
2677 | + } |
|
2678 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2679 | + } |
|
2680 | + } |
|
2681 | + } |
|
2682 | + |
|
2683 | + /** |
|
2684 | + * Restore works |
|
2685 | 2685 | * @deprecated use restore_works |
2686 | 2686 | * |
2687 | - */ |
|
2688 | - public function restore_student_publication($sessionId = 0) |
|
2687 | + */ |
|
2688 | + public function restore_student_publication($sessionId = 0) |
|
2689 | 2689 | { |
2690 | 2690 | $sessionId = intval($sessionId); |
2691 | - $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2692 | - $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
2693 | - $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2691 | + $work_assignment_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
2692 | + $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
2693 | + $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
2694 | 2694 | |
2695 | - // Query in student publication |
|
2696 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2695 | + // Query in student publication |
|
2696 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2697 | 2697 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2698 | 2698 | |
2699 | - $result = Database::query($sql); |
|
2700 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2699 | + $result = Database::query($sql); |
|
2700 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2701 | 2701 | |
2702 | - foreach ($folders as $folder) { |
|
2703 | - $old_id = $folder['id']; |
|
2702 | + foreach ($folders as $folder) { |
|
2703 | + $old_id = $folder['id']; |
|
2704 | 2704 | unset($folder['id']); |
2705 | - $folder['c_id'] = $this->destination_course_id; |
|
2705 | + $folder['c_id'] = $this->destination_course_id; |
|
2706 | 2706 | $folder['parent_id'] = 0; |
2707 | 2707 | $folder['session_id'] = $sessionId; |
2708 | - $new_id = Database::insert($work_table, $folder); |
|
2708 | + $new_id = Database::insert($work_table, $folder); |
|
2709 | 2709 | |
2710 | 2710 | if ($new_id) { |
2711 | 2711 | //query in item property |
@@ -2764,21 +2764,21 @@ discard block |
||
2764 | 2764 | } |
2765 | 2765 | } |
2766 | 2766 | } |
2767 | - } |
|
2767 | + } |
|
2768 | 2768 | |
2769 | - $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
2770 | - $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
2771 | - self::allow_create_all_directory($origin,$destination,false); |
|
2772 | - } |
|
2769 | + $destination = '../../courses/'.$this->course->destination_path.'/work/'; |
|
2770 | + $origin = '../../courses/'.$this->course->info['path'].'/work/'; |
|
2771 | + self::allow_create_all_directory($origin,$destination,false); |
|
2772 | + } |
|
2773 | 2773 | |
2774 | 2774 | /** |
2775 | - * copy all directory and sub directory |
|
2776 | - * @param string The path origin |
|
2777 | - * @param string The path destination |
|
2778 | - * @param boolean Option Overwrite |
|
2779 | - * @return void() |
|
2780 | - * @deprecated |
|
2781 | - */ |
|
2775 | + * copy all directory and sub directory |
|
2776 | + * @param string The path origin |
|
2777 | + * @param string The path destination |
|
2778 | + * @param boolean Option Overwrite |
|
2779 | + * @return void() |
|
2780 | + * @deprecated |
|
2781 | + */ |
|
2782 | 2782 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2783 | 2783 | { |
2784 | 2784 | if (!is_dir($dest)) { |
@@ -2789,14 +2789,14 @@ discard block |
||
2789 | 2789 | if ($file != '.' && $file != '..') { |
2790 | 2790 | $path = $source . '/' . $file; |
2791 | 2791 | if (is_file($path)) { |
2792 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2792 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2793 | 2793 | if (!@copy($path, $dest . '/' . $file)) { |
2794 | 2794 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2795 | 2795 | }*/ |
2796 | 2796 | } elseif(is_dir($path)) { |
2797 | 2797 | if (!is_dir($dest . '/' . $file)) |
2798 | 2798 | mkdir($dest . '/' . $file); |
2799 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2799 | + self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
2800 | 2800 | } |
2801 | 2801 | } |
2802 | 2802 | } |
@@ -2804,12 +2804,12 @@ discard block |
||
2804 | 2804 | } |
2805 | 2805 | } |
2806 | 2806 | |
2807 | - /** |
|
2808 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2809 | - * @param string Tool name |
|
2810 | - * @param integer Old ID |
|
2811 | - * @return integer New ID |
|
2812 | - */ |
|
2807 | + /** |
|
2808 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2809 | + * @param string Tool name |
|
2810 | + * @param integer Old ID |
|
2811 | + * @return integer New ID |
|
2812 | + */ |
|
2813 | 2813 | public function get_new_id($tool, $ref) |
2814 | 2814 | { |
2815 | 2815 | // Check if the value exist in the current array. |
@@ -2831,25 +2831,25 @@ discard block |
||
2831 | 2831 | } |
2832 | 2832 | |
2833 | 2833 | return ''; |
2834 | - } |
|
2834 | + } |
|
2835 | 2835 | |
2836 | - /** |
|
2837 | - * Restore glossary |
|
2838 | - */ |
|
2836 | + /** |
|
2837 | + * Restore glossary |
|
2838 | + */ |
|
2839 | 2839 | public function restore_glossary($session_id = 0) |
2840 | 2840 | { |
2841 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2842 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2843 | - $resources = $this->course->resources; |
|
2844 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2841 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2842 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2843 | + $resources = $this->course->resources; |
|
2844 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2845 | 2845 | |
2846 | 2846 | $params = []; |
2847 | - if (!empty($session_id)) { |
|
2848 | - $session_id = intval($session_id); |
|
2847 | + if (!empty($session_id)) { |
|
2848 | + $session_id = intval($session_id); |
|
2849 | 2849 | $params['session_id'] = $session_id; |
2850 | - } |
|
2850 | + } |
|
2851 | 2851 | |
2852 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2852 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2853 | 2853 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2854 | 2854 | $glossary->description, |
2855 | 2855 | $this->course->code, |
@@ -2883,27 +2883,27 @@ discard block |
||
2883 | 2883 | |
2884 | 2884 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2885 | 2885 | } |
2886 | - } |
|
2887 | - } |
|
2888 | - } |
|
2886 | + } |
|
2887 | + } |
|
2888 | + } |
|
2889 | 2889 | |
2890 | 2890 | /** |
2891 | 2891 | * @param int $session_id |
2892 | 2892 | */ |
2893 | 2893 | public function restore_wiki($session_id = 0) |
2894 | 2894 | { |
2895 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2896 | - // wiki table of the target course |
|
2897 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2898 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2895 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2896 | + // wiki table of the target course |
|
2897 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2898 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2899 | 2899 | |
2900 | - // storing all the resources that have to be copied in an array |
|
2901 | - $resources = $this->course->resources; |
|
2900 | + // storing all the resources that have to be copied in an array |
|
2901 | + $resources = $this->course->resources; |
|
2902 | 2902 | |
2903 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2904 | - // the sql statement to insert the groups from the old course to the new course |
|
2903 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2904 | + // the sql statement to insert the groups from the old course to the new course |
|
2905 | 2905 | |
2906 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2906 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2907 | 2907 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2908 | 2908 | $wiki->content, |
2909 | 2909 | $this->course->code, |
@@ -2926,7 +2926,7 @@ discard block |
||
2926 | 2926 | 'session_id' => !empty($session_id) ? intval($session_id) : 0, |
2927 | 2927 | ]; |
2928 | 2928 | |
2929 | - $new_id = Database::insert($table_wiki, $params); |
|
2929 | + $new_id = Database::insert($table_wiki, $params); |
|
2930 | 2930 | |
2931 | 2931 | if ($new_id) { |
2932 | 2932 | |
@@ -2957,9 +2957,9 @@ discard block |
||
2957 | 2957 | |
2958 | 2958 | Database::insert($table_wiki_conf, $params); |
2959 | 2959 | } |
2960 | - } |
|
2961 | - } |
|
2962 | - } |
|
2960 | + } |
|
2961 | + } |
|
2962 | + } |
|
2963 | 2963 | |
2964 | 2964 | /** |
2965 | 2965 | * Restore Thematics |
@@ -2967,15 +2967,15 @@ discard block |
||
2967 | 2967 | */ |
2968 | 2968 | public function restore_thematic($session_id = 0) |
2969 | 2969 | { |
2970 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2970 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2971 | 2971 | $table_thematic = Database:: get_course_table(TABLE_THEMATIC); |
2972 | 2972 | $table_thematic_advance = Database:: get_course_table(TABLE_THEMATIC_ADVANCE); |
2973 | 2973 | $table_thematic_plan = Database:: get_course_table(TABLE_THEMATIC_PLAN); |
2974 | 2974 | |
2975 | - $resources = $this->course->resources; |
|
2976 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2975 | + $resources = $this->course->resources; |
|
2976 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
2977 | 2977 | |
2978 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2978 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2979 | 2979 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2980 | 2980 | $thematic->params['content'], |
2981 | 2981 | $this->course->code, |
@@ -2983,13 +2983,13 @@ discard block |
||
2983 | 2983 | $this->course->backup_path, |
2984 | 2984 | $this->course->info['path'] |
2985 | 2985 | ); |
2986 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
2987 | - unset($thematic->params['id']); |
|
2986 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
2987 | + unset($thematic->params['id']); |
|
2988 | 2988 | unset($thematic->params['iid']); |
2989 | 2989 | |
2990 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
2990 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
2991 | 2991 | |
2992 | - if ($last_id) { |
|
2992 | + if ($last_id) { |
|
2993 | 2993 | |
2994 | 2994 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
2995 | 2995 | Database::query($sql); |
@@ -3002,19 +3002,19 @@ discard block |
||
3002 | 3002 | api_get_user_id() |
3003 | 3003 | ); |
3004 | 3004 | |
3005 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3006 | - unset($thematic_advance['id']); |
|
3005 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3006 | + unset($thematic_advance['id']); |
|
3007 | 3007 | unset($thematic_advance['iid']); |
3008 | - $thematic_advance['attendance_id'] = 0; |
|
3009 | - $thematic_advance['thematic_id'] = $last_id; |
|
3010 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3008 | + $thematic_advance['attendance_id'] = 0; |
|
3009 | + $thematic_advance['thematic_id'] = $last_id; |
|
3010 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3011 | 3011 | $my_id = Database::insert( |
3012 | 3012 | $table_thematic_advance, |
3013 | 3013 | $thematic_advance, |
3014 | 3014 | false |
3015 | 3015 | ); |
3016 | 3016 | |
3017 | - if ($my_id) { |
|
3017 | + if ($my_id) { |
|
3018 | 3018 | |
3019 | 3019 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
3020 | 3020 | Database::query($sql); |
@@ -3026,17 +3026,17 @@ discard block |
||
3026 | 3026 | "ThematicAdvanceAdded", |
3027 | 3027 | api_get_user_id() |
3028 | 3028 | ); |
3029 | - } |
|
3030 | - } |
|
3029 | + } |
|
3030 | + } |
|
3031 | 3031 | |
3032 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3033 | - unset($thematic_plan['id']); |
|
3032 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3033 | + unset($thematic_plan['id']); |
|
3034 | 3034 | unset($thematic_plan['iid']); |
3035 | - $thematic_plan['thematic_id'] = $last_id; |
|
3036 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
3037 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3035 | + $thematic_plan['thematic_id'] = $last_id; |
|
3036 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
3037 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3038 | 3038 | |
3039 | - if ($my_id) { |
|
3039 | + if ($my_id) { |
|
3040 | 3040 | |
3041 | 3041 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
3042 | 3042 | Database::query($sql); |
@@ -3048,12 +3048,12 @@ discard block |
||
3048 | 3048 | "ThematicPlanAdded", |
3049 | 3049 | api_get_user_id() |
3050 | 3050 | ); |
3051 | - } |
|
3052 | - } |
|
3053 | - } |
|
3054 | - } |
|
3055 | - } |
|
3056 | - } |
|
3051 | + } |
|
3052 | + } |
|
3053 | + } |
|
3054 | + } |
|
3055 | + } |
|
3056 | + } |
|
3057 | 3057 | |
3058 | 3058 | /** |
3059 | 3059 | * Restore Attendance |
@@ -3061,14 +3061,14 @@ discard block |
||
3061 | 3061 | */ |
3062 | 3062 | public function restore_attendance($session_id = 0) |
3063 | 3063 | { |
3064 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3065 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3066 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3064 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3065 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3066 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3067 | 3067 | |
3068 | - $resources = $this->course->resources; |
|
3069 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3068 | + $resources = $this->course->resources; |
|
3069 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3070 | 3070 | |
3071 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3071 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3072 | 3072 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3073 | 3073 | $obj->params['description'], |
3074 | 3074 | $this->course->code, |
@@ -3080,11 +3080,11 @@ discard block |
||
3080 | 3080 | unset($obj->params['id']); |
3081 | 3081 | unset($obj->params['iid']); |
3082 | 3082 | |
3083 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3083 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3084 | 3084 | |
3085 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3085 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3086 | 3086 | |
3087 | - if (is_numeric($last_id)) { |
|
3087 | + if (is_numeric($last_id)) { |
|
3088 | 3088 | |
3089 | 3089 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3090 | 3090 | Database::query($sql); |
@@ -3098,11 +3098,11 @@ discard block |
||
3098 | 3098 | ); |
3099 | 3099 | |
3100 | 3100 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3101 | - unset($attendance_calendar['id']); |
|
3101 | + unset($attendance_calendar['id']); |
|
3102 | 3102 | unset($attendance_calendar['iid']); |
3103 | 3103 | |
3104 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3105 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3104 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3105 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3106 | 3106 | $attendanceCalendarId = Database::insert( |
3107 | 3107 | $table_attendance_calendar, |
3108 | 3108 | $attendance_calendar |
@@ -3110,11 +3110,11 @@ discard block |
||
3110 | 3110 | |
3111 | 3111 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3112 | 3112 | Database::query($sql); |
3113 | - } |
|
3114 | - } |
|
3115 | - } |
|
3116 | - } |
|
3117 | - } |
|
3113 | + } |
|
3114 | + } |
|
3115 | + } |
|
3116 | + } |
|
3117 | + } |
|
3118 | 3118 | |
3119 | 3119 | /** |
3120 | 3120 | * Restore Works |
@@ -3256,11 +3256,11 @@ discard block |
||
3256 | 3256 | */ |
3257 | 3257 | public function DBUTF8($str) |
3258 | 3258 | { |
3259 | - if (UTF8_CONVERT) { |
|
3259 | + if (UTF8_CONVERT) { |
|
3260 | 3260 | $str = utf8_encode($str); |
3261 | 3261 | } |
3262 | - return $str; |
|
3263 | - } |
|
3262 | + return $str; |
|
3263 | + } |
|
3264 | 3264 | |
3265 | 3265 | /** |
3266 | 3266 | * @param string $str |
@@ -3271,8 +3271,8 @@ discard block |
||
3271 | 3271 | if (UTF8_CONVERT) { |
3272 | 3272 | $str = utf8_encode($str); |
3273 | 3273 | } |
3274 | - return Database::escape_string($str); |
|
3275 | - } |
|
3274 | + return Database::escape_string($str); |
|
3275 | + } |
|
3276 | 3276 | |
3277 | 3277 | /** |
3278 | 3278 | * @param array $array |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | $slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null; |
16 | 16 | |
17 | 17 | if (empty($slide_id)) { |
18 | - $edit_slide_id = 1; |
|
18 | + $edit_slide_id = 1; |
|
19 | 19 | } else { |
20 | - $edit_slide_id = $slide_id; |
|
20 | + $edit_slide_id = $slide_id; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if ($path != '/') { |
24 | - $folder = $path.'/'; |
|
24 | + $folder = $path.'/'; |
|
25 | 25 | } else { |
26 | - $folder = '/'; |
|
26 | + $folder = '/'; |
|
27 | 27 | } |
28 | 28 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
29 | 29 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | |
42 | 42 | // Loading the slides from the session |
43 | 43 | if (isset($_SESSION['image_files_only'])) { |
44 | - $image_files_only = $_SESSION['image_files_only']; |
|
44 | + $image_files_only = $_SESSION['image_files_only']; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // Calculating the current slide, next slide, previous slide and the number of slides |
48 | 48 | $slide = null; |
49 | 49 | if ($slide_id != 'all') { |
50 | - $slide = $slide_id ? $slide_id : 0; |
|
51 | - $previous_slide = $slide - 1; |
|
52 | - $next_slide = $slide + 1; |
|
50 | + $slide = $slide_id ? $slide_id : 0; |
|
51 | + $previous_slide = $slide - 1; |
|
52 | + $next_slide = $slide + 1; |
|
53 | 53 | } |
54 | 54 | $total_slides = count($image_files_only); |
55 | 55 | ?> |
@@ -62,62 +62,62 @@ discard block |
||
62 | 62 | <?php |
63 | 63 | |
64 | 64 | if ($slide_id != 'all') { |
65 | - $image = null; |
|
66 | - if (isset($image_files_only[$slide])) { |
|
67 | - $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
68 | - } |
|
69 | - if (file_exists($image)) { |
|
70 | - echo '<div class="actions-pagination">'; |
|
71 | - |
|
72 | - // Back forward buttons |
|
73 | - if ($slide == 0) { |
|
74 | - $imgp = 'action_prev_na.png'; |
|
75 | - $first = Display::return_icon('action_first_na.png'); |
|
76 | - } else { |
|
77 | - $imgp = 'action_prev.png'; |
|
78 | - $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
65 | + $image = null; |
|
66 | + if (isset($image_files_only[$slide])) { |
|
67 | + $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
68 | + } |
|
69 | + if (file_exists($image)) { |
|
70 | + echo '<div class="actions-pagination">'; |
|
71 | + |
|
72 | + // Back forward buttons |
|
73 | + if ($slide == 0) { |
|
74 | + $imgp = 'action_prev_na.png'; |
|
75 | + $first = Display::return_icon('action_first_na.png'); |
|
76 | + } else { |
|
77 | + $imgp = 'action_prev.png'; |
|
78 | + $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
79 | 79 | '.Display::return_icon('action_first.png', get_lang('FirstSlide')).' |
80 | 80 | </a>'; |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - // First slide |
|
84 | - echo $first; |
|
83 | + // First slide |
|
84 | + echo $first; |
|
85 | 85 | |
86 | - // Previous slide |
|
87 | - if ($slide > 0) { |
|
88 | - echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
89 | - } |
|
86 | + // Previous slide |
|
87 | + if ($slide > 0) { |
|
88 | + echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | echo Display::return_icon($imgp, get_lang('Previous')); |
92 | - if ($slide > 0) { |
|
93 | - echo '</a>'; |
|
94 | - } |
|
95 | - |
|
96 | - // Divider |
|
97 | - echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
98 | - |
|
99 | - // Next slide |
|
100 | - if ($slide < $total_slides - 1) { |
|
101 | - echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
102 | - } |
|
103 | - if ($slide == $total_slides - 1) { |
|
104 | - $imgn = 'action_next_na.png'; |
|
92 | + if ($slide > 0) { |
|
93 | + echo '</a>'; |
|
94 | + } |
|
95 | + |
|
96 | + // Divider |
|
97 | + echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
98 | + |
|
99 | + // Next slide |
|
100 | + if ($slide < $total_slides - 1) { |
|
101 | + echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
102 | + } |
|
103 | + if ($slide == $total_slides - 1) { |
|
104 | + $imgn = 'action_next_na.png'; |
|
105 | 105 | $last = Display::return_icon('action_last_na.png', get_lang('LastSlide')); |
106 | - } else { |
|
107 | - $imgn = 'action_next.png'; |
|
108 | - $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"> |
|
106 | + } else { |
|
107 | + $imgn = 'action_next.png'; |
|
108 | + $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"> |
|
109 | 109 | '.Display::return_icon('action_last.png', get_lang('LastSlide')).' |
110 | 110 | </a>'; |
111 | - } |
|
111 | + } |
|
112 | 112 | echo Display::return_icon($imgn, get_lang('Next')); |
113 | - if ($slide > 0) { |
|
114 | - echo '</a>'; |
|
115 | - } |
|
116 | - |
|
117 | - // Last slide |
|
118 | - echo $last; |
|
119 | - echo '</div>'; |
|
120 | - } |
|
113 | + if ($slide > 0) { |
|
114 | + echo '</a>'; |
|
115 | + } |
|
116 | + |
|
117 | + // Last slide |
|
118 | + echo $last; |
|
119 | + echo '</div>'; |
|
120 | + } |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Exit the slideshow |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | |
127 | 127 | // Show thumbnails |
128 | 128 | if ($slide_id != 'all') { |
129 | - echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
129 | + echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
130 | 130 | Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>'; |
131 | 131 | } else { |
132 | - echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
132 | + echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
133 | 133 | } |
134 | 134 | // Slideshow options |
135 | 135 | echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
@@ -142,24 +142,24 @@ discard block |
||
142 | 142 | |
143 | 143 | // If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options |
144 | 144 | if (isset($_POST['Submit'])) { |
145 | - // We come from slideshowoptions.php |
|
146 | - //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
147 | - $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
148 | - if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
149 | - //echo "resizing"; |
|
150 | - $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
151 | - $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
152 | - } else { |
|
153 | - //echo "unsetting the session heighte and width"; |
|
154 | - $_SESSION["image_resizing_width"] = null; |
|
155 | - $_SESSION["image_resizing_height"] = null; |
|
156 | - } |
|
145 | + // We come from slideshowoptions.php |
|
146 | + //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
147 | + $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
148 | + if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
149 | + //echo "resizing"; |
|
150 | + $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
151 | + $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
152 | + } else { |
|
153 | + //echo "unsetting the session heighte and width"; |
|
154 | + $_SESSION["image_resizing_width"] = null; |
|
155 | + $_SESSION["image_resizing_height"] = null; |
|
156 | + } |
|
157 | 157 | } |
158 | 158 | $target_width = $target_height = null; |
159 | 159 | // The target height and width depends if we choose resizing or no resizing |
160 | 160 | if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") { |
161 | - $target_width = $_SESSION["image_resizing_width"]; |
|
162 | - $target_height = $_SESSION["image_resizing_height"]; |
|
161 | + $target_width = $_SESSION["image_resizing_width"]; |
|
162 | + $target_height = $_SESSION["image_resizing_height"]; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /* THUMBNAIL VIEW */ |
@@ -169,59 +169,59 @@ discard block |
||
169 | 169 | $html = ''; |
170 | 170 | if ($slide_id == 'all') { |
171 | 171 | |
172 | - // Config for make thumbnails |
|
172 | + // Config for make thumbnails |
|
173 | 173 | $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png'); |
174 | - $max_thumbnail_width = 250; |
|
175 | - $max_thumbnail_height = 250; |
|
176 | - $png_compression = 0; // 0(none)-9 |
|
177 | - $jpg_quality = 75; // from 0 to 100 (default is 75). More quality less compression |
|
174 | + $max_thumbnail_width = 250; |
|
175 | + $max_thumbnail_height = 250; |
|
176 | + $png_compression = 0; // 0(none)-9 |
|
177 | + $jpg_quality = 75; // from 0 to 100 (default is 75). More quality less compression |
|
178 | 178 | |
179 | - $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
179 | + $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
180 | 180 | |
181 | - //Other parameters only for show tumbnails |
|
182 | - $row_items = 4;//only in slideshow.php |
|
183 | - $number_image = 7;//num icons cols to show |
|
184 | - $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
185 | - $thumbnail_height_frame = $max_thumbnail_height; |
|
181 | + //Other parameters only for show tumbnails |
|
182 | + $row_items = 4;//only in slideshow.php |
|
183 | + $number_image = 7;//num icons cols to show |
|
184 | + $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
185 | + $thumbnail_height_frame = $max_thumbnail_height; |
|
186 | 186 | |
187 | - // Create the template_thumbnails folder (if no exist) |
|
187 | + // Create the template_thumbnails folder (if no exist) |
|
188 | 188 | |
189 | - if (!file_exists($directory_thumbnails)) { |
|
190 | - @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
189 | + if (!file_exists($directory_thumbnails)) { |
|
190 | + @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
191 | 191 | } |
192 | 192 | |
193 | - // check files and thumbnails |
|
194 | - if (is_array($image_files_only)) { |
|
193 | + // check files and thumbnails |
|
194 | + if (is_array($image_files_only)) { |
|
195 | 195 | |
196 | - foreach ($image_files_only as $one_image_file) { |
|
197 | - $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
198 | - $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
196 | + foreach ($image_files_only as $one_image_file) { |
|
197 | + $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
198 | + $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
199 | 199 | |
200 | - if (file_exists($image)) { |
|
201 | - //check thumbnail |
|
202 | - $imagetype = explode(".", $image); |
|
200 | + if (file_exists($image)) { |
|
201 | + //check thumbnail |
|
202 | + $imagetype = explode(".", $image); |
|
203 | 203 | //or check $imagetype = image_type_to_extension(exif_imagetype($image), false); |
204 | - $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
204 | + $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
205 | 205 | |
206 | - if (in_array($imagetype,$allowed_thumbnail_types)) { |
|
207 | - if (!file_exists($image_thumbnail)){ |
|
206 | + if (in_array($imagetype,$allowed_thumbnail_types)) { |
|
207 | + if (!file_exists($image_thumbnail)){ |
|
208 | 208 | //run each once we view thumbnails is too heavy, then need move into !file_exists($image_thumbnail, and only run when haven't the thumbnail |
209 | - $original_image_size = api_getimagesize($image); |
|
210 | - |
|
211 | - switch($imagetype) { |
|
212 | - case 'gif': |
|
213 | - $source_img = imagecreatefromgif($image); |
|
214 | - break; |
|
215 | - case 'jpg': |
|
216 | - $source_img = imagecreatefromjpeg($image); |
|
217 | - break; |
|
218 | - case 'jpeg': |
|
219 | - $source_img = imagecreatefromjpeg($image); |
|
220 | - break; |
|
221 | - case 'png': |
|
222 | - $source_img = imagecreatefrompng($image); |
|
223 | - break; |
|
224 | - } |
|
209 | + $original_image_size = api_getimagesize($image); |
|
210 | + |
|
211 | + switch($imagetype) { |
|
212 | + case 'gif': |
|
213 | + $source_img = imagecreatefromgif($image); |
|
214 | + break; |
|
215 | + case 'jpg': |
|
216 | + $source_img = imagecreatefromjpeg($image); |
|
217 | + break; |
|
218 | + case 'jpeg': |
|
219 | + $source_img = imagecreatefromjpeg($image); |
|
220 | + break; |
|
221 | + case 'png': |
|
222 | + $source_img = imagecreatefrompng($image); |
|
223 | + break; |
|
224 | + } |
|
225 | 225 | |
226 | 226 | $new_thumbnail_size = api_calculate_image_size( |
227 | 227 | $original_image_size['width'], |
@@ -229,33 +229,33 @@ discard block |
||
229 | 229 | $max_thumbnail_width, |
230 | 230 | $max_thumbnail_height |
231 | 231 | ); |
232 | - if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
233 | - $new_thumbnail_size['width']=$original_image_size['width']; |
|
234 | - $new_thumbnail_size['height']=$original_image_size['height']; |
|
235 | - } |
|
236 | - |
|
237 | - $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
238 | - |
|
239 | - // preserve transparency |
|
240 | - if ($imagetype == "png"){ |
|
241 | - imagesavealpha($crop, true); |
|
242 | - $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
243 | - imagefill($crop, 0, 0, $color); |
|
244 | - } |
|
245 | - |
|
246 | - if ($imagetype == "gif") { |
|
247 | - $transindex = imagecolortransparent($source_img); |
|
232 | + if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
233 | + $new_thumbnail_size['width']=$original_image_size['width']; |
|
234 | + $new_thumbnail_size['height']=$original_image_size['height']; |
|
235 | + } |
|
236 | + |
|
237 | + $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
238 | + |
|
239 | + // preserve transparency |
|
240 | + if ($imagetype == "png"){ |
|
241 | + imagesavealpha($crop, true); |
|
242 | + $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
243 | + imagefill($crop, 0, 0, $color); |
|
244 | + } |
|
245 | + |
|
246 | + if ($imagetype == "gif") { |
|
247 | + $transindex = imagecolortransparent($source_img); |
|
248 | 248 | $palletsize = imagecolorstotal($source_img); |
249 | - //GIF89a for transparent and anim (first clip), either GIF87a |
|
250 | - if ($transindex >= 0 && $transindex < $palletsize){ |
|
251 | - $transcol = imagecolorsforindex($source_img, $transindex); |
|
252 | - $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
253 | - imagefill($crop, 0, 0, $transindex); |
|
254 | - imagecolortransparent($crop, $transindex); |
|
255 | - } |
|
256 | - } |
|
257 | - |
|
258 | - //resampled image |
|
249 | + //GIF89a for transparent and anim (first clip), either GIF87a |
|
250 | + if ($transindex >= 0 && $transindex < $palletsize){ |
|
251 | + $transcol = imagecolorsforindex($source_img, $transindex); |
|
252 | + $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
253 | + imagefill($crop, 0, 0, $transindex); |
|
254 | + imagecolortransparent($crop, $transindex); |
|
255 | + } |
|
256 | + } |
|
257 | + |
|
258 | + //resampled image |
|
259 | 259 | imagecopyresampled( |
260 | 260 | $crop, |
261 | 261 | $source_img, |
@@ -269,69 +269,69 @@ discard block |
||
269 | 269 | $original_image_size['height'] |
270 | 270 | ); |
271 | 271 | |
272 | - switch ($imagetype) { |
|
273 | - case 'gif': |
|
274 | - imagegif($crop,$image_thumbnail); |
|
275 | - break; |
|
276 | - case 'jpg': |
|
277 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
278 | - break; |
|
279 | - case 'jpeg': |
|
280 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
281 | - break; |
|
282 | - case 'png': |
|
283 | - imagepng($crop,$image_thumbnail,$png_compression); |
|
284 | - break; |
|
285 | - } |
|
286 | - |
|
287 | - //clean memory |
|
288 | - imagedestroy($crop); |
|
289 | - }//end !exist thumbnail |
|
290 | - |
|
291 | - //show thumbnail and link |
|
292 | - |
|
293 | - $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
294 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
295 | - $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
296 | - } else { |
|
297 | - //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
298 | - if ($imagetype=="bmp") { |
|
272 | + switch ($imagetype) { |
|
273 | + case 'gif': |
|
274 | + imagegif($crop,$image_thumbnail); |
|
275 | + break; |
|
276 | + case 'jpg': |
|
277 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
278 | + break; |
|
279 | + case 'jpeg': |
|
280 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
281 | + break; |
|
282 | + case 'png': |
|
283 | + imagepng($crop,$image_thumbnail,$png_compression); |
|
284 | + break; |
|
285 | + } |
|
286 | + |
|
287 | + //clean memory |
|
288 | + imagedestroy($crop); |
|
289 | + }//end !exist thumbnail |
|
290 | + |
|
291 | + //show thumbnail and link |
|
292 | + |
|
293 | + $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
294 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
295 | + $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
296 | + } else { |
|
297 | + //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
298 | + if ($imagetype=="bmp") { |
|
299 | 299 | // use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy |
300 | - $original_image_size = getimagesize($image); |
|
301 | - if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
302 | - $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
303 | - $image_height = $thumbnail_size['height']; |
|
304 | - $image_width = $thumbnail_size['width']; |
|
305 | - } else { |
|
306 | - $image_height=$original_image_size[0]; |
|
307 | - $image_width=$original_image_size[1]; |
|
308 | - } |
|
309 | - } else { |
|
310 | - //example for svg files,... |
|
311 | - $image_width=$max_thumbnail_width; |
|
312 | - $image_height=$max_thumbnail_height; |
|
313 | - } |
|
314 | - |
|
315 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
316 | - $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
317 | - |
|
318 | - }//end allowed image types |
|
319 | - }//end if exist file image |
|
320 | - }//end foreach |
|
321 | - }//end image files only |
|
322 | - |
|
323 | - // Creating the table |
|
324 | - $html_table = ''; |
|
325 | - |
|
326 | - $i = 0; |
|
327 | - $count_image = count($image_tag); |
|
328 | - $number_iteration = ceil($count_image/$number_image); |
|
329 | - $p = 0; |
|
300 | + $original_image_size = getimagesize($image); |
|
301 | + if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
302 | + $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
303 | + $image_height = $thumbnail_size['height']; |
|
304 | + $image_width = $thumbnail_size['width']; |
|
305 | + } else { |
|
306 | + $image_height=$original_image_size[0]; |
|
307 | + $image_width=$original_image_size[1]; |
|
308 | + } |
|
309 | + } else { |
|
310 | + //example for svg files,... |
|
311 | + $image_width=$max_thumbnail_width; |
|
312 | + $image_height=$max_thumbnail_height; |
|
313 | + } |
|
314 | + |
|
315 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
316 | + $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
317 | + |
|
318 | + }//end allowed image types |
|
319 | + }//end if exist file image |
|
320 | + }//end foreach |
|
321 | + }//end image files only |
|
322 | + |
|
323 | + // Creating the table |
|
324 | + $html_table = ''; |
|
325 | + |
|
326 | + $i = 0; |
|
327 | + $count_image = count($image_tag); |
|
328 | + $number_iteration = ceil($count_image/$number_image); |
|
329 | + $p = 0; |
|
330 | 330 | $html = ''; |
331 | 331 | $html .= '<div class="gallery">'; |
332 | - for ($k = 0; $k < $number_iteration; $k++) { |
|
333 | - for ($i = 0; $i < $number_image; $i++) { |
|
334 | - if (isset($image_tag[$p])) { |
|
332 | + for ($k = 0; $k < $number_iteration; $k++) { |
|
333 | + for ($i = 0; $i < $number_image; $i++) { |
|
334 | + if (isset($image_tag[$p])) { |
|
335 | 335 | $html .= '<div class="col-xs-6 col-sm-3 col-md-2">'; |
336 | 336 | $html .= '<div class="canvas-one">'; |
337 | 337 | $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">'; |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | $html .= '</a>'; |
344 | 344 | $html .= '</div>'; |
345 | 345 | $html .= '</div>'; |
346 | - } |
|
347 | - $p++; |
|
348 | - } |
|
349 | - } |
|
346 | + } |
|
347 | + $p++; |
|
348 | + } |
|
349 | + } |
|
350 | 350 | $html .= '</div>'; |
351 | 351 | |
352 | 352 | }//end slide==all |
@@ -357,43 +357,43 @@ discard block |
||
357 | 357 | // This is for viewing all the images in the slideshow one at a time. |
358 | 358 | |
359 | 359 | if ($slide_id != 'all' && !empty($image_files_only)) { |
360 | - if (file_exists($image) && is_file($image)) { |
|
361 | - $image_height_width = resize_image($image, $target_width, $target_height); |
|
362 | - |
|
363 | - $image_height = $image_height_width[0]; |
|
364 | - $image_width = $image_height_width[1]; |
|
365 | - |
|
366 | - $height_width_tags = null; |
|
367 | - if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
368 | - $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
369 | - } |
|
370 | - |
|
371 | - // This is done really quickly and should be cleaned up a little bit using the API functions |
|
372 | - $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
373 | - if ($path == '/') { |
|
374 | - $pathpart = '/'; |
|
375 | - } else { |
|
376 | - $pathpart = $path.'/'; |
|
377 | - } |
|
378 | - $sql = "SELECT * FROM $tbl_documents |
|
360 | + if (file_exists($image) && is_file($image)) { |
|
361 | + $image_height_width = resize_image($image, $target_width, $target_height); |
|
362 | + |
|
363 | + $image_height = $image_height_width[0]; |
|
364 | + $image_width = $image_height_width[1]; |
|
365 | + |
|
366 | + $height_width_tags = null; |
|
367 | + if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
368 | + $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
369 | + } |
|
370 | + |
|
371 | + // This is done really quickly and should be cleaned up a little bit using the API functions |
|
372 | + $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
373 | + if ($path == '/') { |
|
374 | + $pathpart = '/'; |
|
375 | + } else { |
|
376 | + $pathpart = $path.'/'; |
|
377 | + } |
|
378 | + $sql = "SELECT * FROM $tbl_documents |
|
379 | 379 | WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'"; |
380 | - $result = Database::query($sql); |
|
381 | - $row = Database::fetch_array($result); |
|
380 | + $result = Database::query($sql); |
|
381 | + $row = Database::fetch_array($result); |
|
382 | 382 | |
383 | 383 | echo '<div class="thumbnail">'; |
384 | - if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
385 | - echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
386 | - } else { |
|
387 | - echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
388 | - } |
|
384 | + if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
385 | + echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
386 | + } else { |
|
387 | + echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
388 | + } |
|
389 | 389 | if ($path == '/') { |
390 | - $path = ''; |
|
390 | + $path = ''; |
|
391 | 391 | } |
392 | 392 | |
393 | - list($width, $height) = getimagesize($image); |
|
394 | - // Auto resize |
|
395 | - if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
396 | - ?> |
|
393 | + list($width, $height) = getimagesize($image); |
|
394 | + // Auto resize |
|
395 | + if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
396 | + ?> |
|
397 | 397 | |
398 | 398 | <script type="text/javascript"> |
399 | 399 | var initial_width='<?php echo $width; ?>'; |
@@ -446,21 +446,21 @@ discard block |
||
446 | 446 | |
447 | 447 | </script> |
448 | 448 | <?php |
449 | - } else { |
|
450 | - echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
451 | - } |
|
449 | + } else { |
|
450 | + echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
451 | + } |
|
452 | 452 | |
453 | - echo '</a>'; |
|
453 | + echo '</a>'; |
|
454 | 454 | echo '<div class="caption text-center">'; |
455 | 455 | echo Display::tag('h3', $row['title']); |
456 | 456 | echo '<p>' . $row['comment'] . '</p>'; |
457 | 457 | echo '</div>'; |
458 | 458 | echo '</div>'; |
459 | 459 | |
460 | - if (api_is_allowed_to_edit(null, true)) { |
|
460 | + if (api_is_allowed_to_edit(null, true)) { |
|
461 | 461 | echo '<ul class="list-unstyled">'; |
462 | - $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
463 | - $ext = $aux[count($aux) - 1]; |
|
462 | + $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
463 | + $ext = $aux[count($aux) - 1]; |
|
464 | 464 | |
465 | 465 | if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
466 | 466 | $resize_info = get_lang('Resizing').'<br />'; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | $resize_height = get_lang('Auto'); |
473 | 473 | } else { |
474 | 474 | $resize_info = get_lang('NoResizing').'<br />'; |
475 | - $resize_width = ''; |
|
476 | - $resize_height = ''; |
|
475 | + $resize_width = ''; |
|
476 | + $resize_height = ''; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | echo '<li class="text-center">'; |
@@ -493,16 +493,16 @@ discard block |
||
493 | 493 | ); |
494 | 494 | echo '</li>'; |
495 | 495 | echo '<li class="text-center">' . $width.' x '.$height . '</li>'; |
496 | - echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>'; |
|
496 | + echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>'; |
|
497 | 497 | echo '<li class="text-center">' . $resize_info . '</li>'; |
498 | - echo '<li class="text-center">' . $resize_width . '</li>'; |
|
499 | - echo '<li class="text-center">' . $resize_height . '</li>'; |
|
498 | + echo '<li class="text-center">' . $resize_width . '</li>'; |
|
499 | + echo '<li class="text-center">' . $resize_height . '</li>'; |
|
500 | 500 | echo '</ul>'; |
501 | - } |
|
501 | + } |
|
502 | 502 | |
503 | - } else { |
|
504 | - Display::display_warning_message(get_lang('FileNotFound')); |
|
505 | - } |
|
503 | + } else { |
|
504 | + Display::display_warning_message(get_lang('FileNotFound')); |
|
505 | + } |
|
506 | 506 | } else { |
507 | 507 | if ($slide_id != 'all') { |
508 | 508 | Display::display_warning_message(get_lang('NoDataAvailable')); |
@@ -24,12 +24,12 @@ |
||
24 | 24 | $actions = array('listing', 'add', 'edit', 'delete', 'history'); |
25 | 25 | $action = 'listing'; |
26 | 26 | if (isset($_GET['action']) && in_array($_GET['action'],$actions)) { |
27 | - $action = $_GET['action']; |
|
27 | + $action = $_GET['action']; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $description_type = ''; |
31 | 31 | if (isset($_GET['description_type'])) { |
32 | - $description_type = intval($_GET['description_type']); |
|
32 | + $description_type = intval($_GET['description_type']); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $id = null; |
@@ -13,39 +13,39 @@ discard block |
||
13 | 13 | // display categories |
14 | 14 | $categories = array (); |
15 | 15 | foreach ($default_description_titles as $id => $title) { |
16 | - $categories[$id] = $title; |
|
16 | + $categories[$id] = $title; |
|
17 | 17 | } |
18 | 18 | $categories[ADD_BLOCK] = get_lang('NewBloc'); |
19 | 19 | |
20 | 20 | $i=1; |
21 | 21 | echo '<div class="actions" style="margin-bottom:30px">'; |
22 | 22 | echo '<a href="index.php?'.api_get_cidreq().'">'. |
23 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
24 | - '</a>'; |
|
23 | + Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM). |
|
24 | + '</a>'; |
|
25 | 25 | ksort($categories); |
26 | 26 | foreach ($categories as $id => $title) { |
27 | - if ($i == ADD_BLOCK) { |
|
28 | - echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
|
29 | - Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>'; |
|
30 | - break; |
|
31 | - } else { |
|
32 | - echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
|
33 | - Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
34 | - $i++; |
|
35 | - } |
|
27 | + if ($i == ADD_BLOCK) { |
|
28 | + echo '<a href="index.php?'.api_get_cidreq().'&action=add">'. |
|
29 | + Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>'; |
|
30 | + break; |
|
31 | + } else { |
|
32 | + echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'. |
|
33 | + Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>'; |
|
34 | + $i++; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | echo '</div>'; |
38 | 38 | |
39 | 39 | // error messages |
40 | 40 | if (isset($error) && intval($error) == 1) { |
41 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false); |
|
41 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // default header title form |
45 | 45 | $header = ''; |
46 | 46 | $description_type = intval($description_type); |
47 | 47 | if ($description_type >= ADD_BLOCK) { |
48 | - $header = $default_description_titles[ADD_BLOCK]; |
|
48 | + $header = $default_description_titles[ADD_BLOCK]; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // display form |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | |
75 | 75 | // display default questions |
76 | 76 | if (isset ($question[$description_type])) { |
77 | - $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />'; |
|
78 | - $message .= $question[$description_type]; |
|
79 | - Display::display_normal_message($message, false); |
|
77 | + $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />'; |
|
78 | + $message .= $question[$description_type]; |
|
79 | + Display::display_normal_message($message, false); |
|
80 | 80 | } |
81 | 81 | $form->display(); |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $reports_template['exercicesMultiCourses'] = array( |
4 | - 'description' => 'Result of each test per student', |
|
5 | - 'getSQL' => 'reports_template_exercicesMultiCourses_getSQL', |
|
6 | - 'wizard' => |
|
4 | + 'description' => 'Result of each test per student', |
|
5 | + 'getSQL' => 'reports_template_exercicesMultiCourses_getSQL', |
|
6 | + 'wizard' => |
|
7 | 7 | ' |
8 | 8 | <span id="exercicesMultiCourses" class="step"> |
9 | 9 | <span class="font_normal_07em_black">Result of each test per student</span><br /> |
@@ -32,39 +32,39 @@ discard block |
||
32 | 32 | '); |
33 | 33 | |
34 | 34 | function reports_template_exercicesMultiCourses_getSQL() { |
35 | - // foreach quiz |
|
36 | - $result = array(); |
|
37 | - $columns = Database::query('select r.id as kid, c.title as course, '. |
|
38 | - 'r.child_name as test from '. |
|
39 | - Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '. |
|
40 | - Database::get_main_table(TABLE_MAIN_COURSE).' c '. |
|
41 | - 'where r.course_id=c.id and r.tool_id='. |
|
42 | - reports_getToolId(TOOL_QUIZ). |
|
43 | - ' order by r.course_id, r.child_name'); |
|
44 | - if (Database::num_rows($columns) == 0) |
|
45 | - die('<b>'.get_lang('no data found').'</b>'); |
|
46 | - $query = 'select u.lastname Name, u.firstname Firstname'; |
|
47 | - $columns = Database::store_result($columns); |
|
48 | - if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max') |
|
49 | - $function = $_REQUEST['tattempt']; |
|
50 | - else |
|
51 | - $function = 'avg'; |
|
52 | - foreach ($columns as $key => $column) |
|
53 | - $query .= ', '.$function.'(k'.$key.'.score) as `'. |
|
54 | - $column['course'].' - '. |
|
55 | - $column['test'].'` '; |
|
56 | - $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
57 | - foreach ($columns as $key => $column) // fixme sessions |
|
58 | - $query .= 'left outer join '. |
|
59 | - Database::get_main_table(TABLE_MAIN_REPORTS_VALUES). |
|
60 | - ' k'.$key. |
|
61 | - ' on k'.$key.'.key_id = '.$column['kid']. |
|
62 | - ' and k'.$key.'.user_id = u.user_id '; |
|
63 | - $query .= ' group by '; |
|
64 | - foreach ($columns as $key => $column) // grouping attempt |
|
65 | - $query .= 'k'.$key.'.attempt, '; |
|
66 | - $query = substr($query, 0, -2); // removing last ', '; |
|
35 | + // foreach quiz |
|
36 | + $result = array(); |
|
37 | + $columns = Database::query('select r.id as kid, c.title as course, '. |
|
38 | + 'r.child_name as test from '. |
|
39 | + Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '. |
|
40 | + Database::get_main_table(TABLE_MAIN_COURSE).' c '. |
|
41 | + 'where r.course_id=c.id and r.tool_id='. |
|
42 | + reports_getToolId(TOOL_QUIZ). |
|
43 | + ' order by r.course_id, r.child_name'); |
|
44 | + if (Database::num_rows($columns) == 0) |
|
45 | + die('<b>'.get_lang('no data found').'</b>'); |
|
46 | + $query = 'select u.lastname Name, u.firstname Firstname'; |
|
47 | + $columns = Database::store_result($columns); |
|
48 | + if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max') |
|
49 | + $function = $_REQUEST['tattempt']; |
|
50 | + else |
|
51 | + $function = 'avg'; |
|
52 | + foreach ($columns as $key => $column) |
|
53 | + $query .= ', '.$function.'(k'.$key.'.score) as `'. |
|
54 | + $column['course'].' - '. |
|
55 | + $column['test'].'` '; |
|
56 | + $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
57 | + foreach ($columns as $key => $column) // fixme sessions |
|
58 | + $query .= 'left outer join '. |
|
59 | + Database::get_main_table(TABLE_MAIN_REPORTS_VALUES). |
|
60 | + ' k'.$key. |
|
61 | + ' on k'.$key.'.key_id = '.$column['kid']. |
|
62 | + ' and k'.$key.'.user_id = u.user_id '; |
|
63 | + $query .= ' group by '; |
|
64 | + foreach ($columns as $key => $column) // grouping attempt |
|
65 | + $query .= 'k'.$key.'.attempt, '; |
|
66 | + $query = substr($query, 0, -2); // removing last ', '; |
|
67 | 67 | |
68 | 68 | |
69 | - return $query; |
|
69 | + return $query; |
|
70 | 70 | } |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | $groupId = api_get_group_id(); |
24 | 24 | |
25 | 25 | if (api_get_setting('enabled_text2audio') == 'false') { |
26 | - api_not_allowed(true); |
|
26 | + api_not_allowed(true); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $document_data = DocumentManager::get_document_data_by_id( |
30 | - $_REQUEST['id'], |
|
31 | - api_get_course_id() |
|
30 | + $_REQUEST['id'], |
|
31 | + api_get_course_id() |
|
32 | 32 | ); |
33 | 33 | if (empty($document_data)) { |
34 | 34 | if (api_is_in_group()) { |
35 | - $group_properties = GroupManager::get_group_properties( |
|
36 | - $groupId |
|
37 | - ); |
|
38 | - $document_id = DocumentManager::get_document_id( |
|
39 | - api_get_course_info(), |
|
40 | - $group_properties['directory'] |
|
41 | - ); |
|
42 | - $document_data = DocumentManager::get_document_data_by_id( |
|
43 | - $document_id, |
|
44 | - api_get_course_id() |
|
45 | - ); |
|
35 | + $group_properties = GroupManager::get_group_properties( |
|
36 | + $groupId |
|
37 | + ); |
|
38 | + $document_id = DocumentManager::get_document_id( |
|
39 | + api_get_course_info(), |
|
40 | + $group_properties['directory'] |
|
41 | + ); |
|
42 | + $document_data = DocumentManager::get_document_data_by_id( |
|
43 | + $document_id, |
|
44 | + api_get_course_id() |
|
45 | + ); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | $document_id = $document_data['id']; |
@@ -55,53 +55,53 @@ discard block |
||
55 | 55 | // Please, do not modify this dirname formatting |
56 | 56 | |
57 | 57 | if (strstr($dir, '..')) { |
58 | - $dir = '/'; |
|
58 | + $dir = '/'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | if ($dir[0] == '.') { |
62 | - $dir = substr($dir, 1); |
|
62 | + $dir = substr($dir, 1); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | if ($dir[0] != '/') { |
66 | - $dir = '/'.$dir; |
|
66 | + $dir = '/'.$dir; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if ($dir[strlen($dir) - 1] != '/') { |
70 | - $dir .= '/'; |
|
70 | + $dir .= '/'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
74 | 74 | |
75 | 75 | if (!is_dir($filepath)) { |
76 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
77 | - $dir = '/'; |
|
76 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
77 | + $dir = '/'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | //groups //TODO: clean |
81 | 81 | if (!empty($groupId)) { |
82 | - $interbreadcrumb[] = array("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace')); |
|
83 | - $group = GroupManager :: get_group_properties($groupId); |
|
84 | - $path = explode('/', $dir); |
|
85 | - if ('/'.$path[1] != $group['directory']) { |
|
86 | - api_not_allowed(true); |
|
87 | - } |
|
82 | + $interbreadcrumb[] = array("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace')); |
|
83 | + $group = GroupManager :: get_group_properties($groupId); |
|
84 | + $path = explode('/', $dir); |
|
85 | + if ('/'.$path[1] != $group['directory']) { |
|
86 | + api_not_allowed(true); |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | $interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents')); |
91 | 91 | |
92 | 92 | if (!$is_allowed_in_course) { |
93 | - api_not_allowed(true); |
|
93 | + api_not_allowed(true); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || |
98 | - DocumentManager::is_my_shared_folder( |
|
99 | - api_get_user_id(), |
|
100 | - Security::remove_XSS($dir), |
|
101 | - api_get_session_id() |
|
102 | - )) |
|
98 | + DocumentManager::is_my_shared_folder( |
|
99 | + api_get_user_id(), |
|
100 | + Security::remove_XSS($dir), |
|
101 | + api_get_session_id() |
|
102 | + )) |
|
103 | 103 | ) { |
104 | - api_not_allowed(true); |
|
104 | + api_not_allowed(true); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | |
111 | 111 | $display_dir = $dir; |
112 | 112 | if (isset ($group)) { |
113 | - $display_dir = explode('/', $dir); |
|
114 | - unset ($display_dir[0]); |
|
115 | - unset ($display_dir[1]); |
|
116 | - $display_dir = implode('/', $display_dir); |
|
113 | + $display_dir = explode('/', $dir); |
|
114 | + unset ($display_dir[0]); |
|
115 | + unset ($display_dir[1]); |
|
116 | + $display_dir = implode('/', $display_dir); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Interbreadcrumb for the current directory root path |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | |
124 | 124 | $dir_acum = ''; |
125 | 125 | for ($i = 0; $i < $array_len; $i++) { |
126 | - $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i]; |
|
127 | - //Max char 80 |
|
128 | - $url_to_who = cut($dir_array[$i],80); |
|
129 | - $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who); |
|
130 | - $dir_acum .= $dir_array[$i].'/'; |
|
126 | + $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i]; |
|
127 | + //Max char 80 |
|
128 | + $url_to_who = cut($dir_array[$i],80); |
|
129 | + $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who); |
|
130 | + $dir_acum .= $dir_array[$i].'/'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | Display :: display_header($nameTools, 'Doc'); |
134 | 134 | |
135 | 135 | echo '<div class="actions">'; |
136 | 136 | echo '<a href="document.php?id='.$document_id.'">'. |
137 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
137 | + Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
138 | 138 | echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&dt2a=google">'. |
139 | - Display::return_icon('google.png',get_lang('GoogleAudio'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
139 | + Display::return_icon('google.png',get_lang('GoogleAudio'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
140 | 140 | echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&dt2a=pediaphon">'. |
141 | - Display::return_icon('pediaphon.png', get_lang('Pediaphon'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
141 | + Display::return_icon('pediaphon.png', get_lang('Pediaphon'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
142 | 142 | echo '</div>'; |
143 | 143 | |
144 | 144 | ?> |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | <?php |
192 | 192 | |
193 | 193 | if (isset($_POST['text2voice_mode']) && $_POST['text2voice_mode'] == 'google') { |
194 | - downloadMP3_google($filepath, $dir); |
|
194 | + downloadMP3_google($filepath, $dir); |
|
195 | 195 | } elseif (isset($_POST['text2voice_mode']) && $_POST['text2voice_mode'] == 'pediaphon') { |
196 | - downloadMP3_pediaphon($filepath, $dir); |
|
196 | + downloadMP3_pediaphon($filepath, $dir); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
@@ -204,65 +204,65 @@ discard block |
||
204 | 204 | $selected_language = null; |
205 | 205 | |
206 | 206 | while ($row = Database::fetch_array($result_select)) { |
207 | - $options[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
208 | - if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))){ |
|
209 | - $options_pedia[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
210 | - } |
|
207 | + $options[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
208 | + if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))){ |
|
209 | + $options_pedia[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
210 | + } |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $icon = Display::return_icon('text2audio.png', get_lang('HelpText2Audio'),'',ICON_SIZE_MEDIUM); |
214 | 214 | echo '<div class="page-header"><h2>'.$icon.get_lang('HelpText2Audio').'</h2></div>'; |
215 | 215 | |
216 | 216 | if (Security::remove_XSS($_GET['dt2a']) == 'google') { |
217 | - $selected_language = api_get_language_isocode();//lang default is the course language |
|
218 | - echo '<div>'; |
|
219 | - $form = new FormValidator('form1', 'post', null, '', array('id' => 'form1')); |
|
220 | - $form->addElement('hidden', 'text2voice_mode', 'google'); |
|
221 | - $form->addElement('hidden', 'id', $document_id); |
|
222 | - $form->addElement('text', 'title', get_lang('Title')); |
|
223 | - $form->addElement('select', 'lang', get_lang('Language'), $options); |
|
224 | - $form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_google')); |
|
225 | - //echo Display :: return_icon('info3.gif', get_lang('HelpGoogleAudio'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
226 | - $form->addButtonSave(get_lang('SaveMP3')); |
|
227 | - $defaults = array(); |
|
228 | - $defaults['lang'] = $selected_language; |
|
229 | - $form->setDefaults($defaults); |
|
230 | - $form->display(); |
|
231 | - |
|
232 | - echo '</div>'; |
|
217 | + $selected_language = api_get_language_isocode();//lang default is the course language |
|
218 | + echo '<div>'; |
|
219 | + $form = new FormValidator('form1', 'post', null, '', array('id' => 'form1')); |
|
220 | + $form->addElement('hidden', 'text2voice_mode', 'google'); |
|
221 | + $form->addElement('hidden', 'id', $document_id); |
|
222 | + $form->addElement('text', 'title', get_lang('Title')); |
|
223 | + $form->addElement('select', 'lang', get_lang('Language'), $options); |
|
224 | + $form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_google')); |
|
225 | + //echo Display :: return_icon('info3.gif', get_lang('HelpGoogleAudio'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
226 | + $form->addButtonSave(get_lang('SaveMP3')); |
|
227 | + $defaults = array(); |
|
228 | + $defaults['lang'] = $selected_language; |
|
229 | + $form->setDefaults($defaults); |
|
230 | + $form->display(); |
|
231 | + |
|
232 | + echo '</div>'; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | if (Security::remove_XSS($_GET['dt2a']) == 'pediaphon') { |
236 | - //lang default is a default message |
|
237 | - $selected_language = "defaultmessage"; |
|
238 | - $options_pedia['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
239 | - $options['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
240 | - echo '<div>'; |
|
241 | - |
|
242 | - $form = new FormValidator('form2', 'post', null, '', array('id' => 'form2')); |
|
243 | - $form->addElement('hidden', 'text2voice_mode','pediaphon'); |
|
244 | - $form->addElement('hidden', 'id', $document_id); |
|
245 | - $form->addElement('text', 'title', get_lang('Title')); |
|
246 | - $form->addElement('select', 'lang', get_lang('Language'), $options_pedia, array('onclick' => 'update_voices(this.selectedIndex);')); |
|
247 | - $form->addElement('select', 'voices', get_lang('Voice'), array(get_lang('FirstSelectALanguage')), array()); |
|
248 | - $speed_options = array(); |
|
249 | - $speed_options['1'] = get_lang('Normal'); |
|
250 | - $speed_options['0.75'] = get_lang('GoFaster'); |
|
251 | - $speed_options['0.8'] = get_lang('Fast'); |
|
252 | - $speed_options['1.2'] = get_lang('Slow'); |
|
253 | - $speed_options['1.6'] = get_lang('SlowDown'); |
|
254 | - |
|
255 | - $form->addElement('select', 'speed', get_lang('Speed'), $speed_options, array()); |
|
256 | - $form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_pediaphon')); |
|
257 | - //echo Display :: return_icon('info3.gif', get_lang('HelpPediaphon'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
258 | - $form->addButtonSave(get_lang('SaveMP3')); |
|
259 | - $defaults = array(); |
|
260 | - $defaults['lang'] = $selected_language; |
|
261 | - $form->setDefaults($defaults); |
|
262 | - $form->display(); |
|
263 | - echo '</div>'; |
|
264 | - |
|
265 | - ?> |
|
236 | + //lang default is a default message |
|
237 | + $selected_language = "defaultmessage"; |
|
238 | + $options_pedia['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
239 | + $options['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
240 | + echo '<div>'; |
|
241 | + |
|
242 | + $form = new FormValidator('form2', 'post', null, '', array('id' => 'form2')); |
|
243 | + $form->addElement('hidden', 'text2voice_mode','pediaphon'); |
|
244 | + $form->addElement('hidden', 'id', $document_id); |
|
245 | + $form->addElement('text', 'title', get_lang('Title')); |
|
246 | + $form->addElement('select', 'lang', get_lang('Language'), $options_pedia, array('onclick' => 'update_voices(this.selectedIndex);')); |
|
247 | + $form->addElement('select', 'voices', get_lang('Voice'), array(get_lang('FirstSelectALanguage')), array()); |
|
248 | + $speed_options = array(); |
|
249 | + $speed_options['1'] = get_lang('Normal'); |
|
250 | + $speed_options['0.75'] = get_lang('GoFaster'); |
|
251 | + $speed_options['0.8'] = get_lang('Fast'); |
|
252 | + $speed_options['1.2'] = get_lang('Slow'); |
|
253 | + $speed_options['1.6'] = get_lang('SlowDown'); |
|
254 | + |
|
255 | + $form->addElement('select', 'speed', get_lang('Speed'), $speed_options, array()); |
|
256 | + $form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_pediaphon')); |
|
257 | + //echo Display :: return_icon('info3.gif', get_lang('HelpPediaphon'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
258 | + $form->addButtonSave(get_lang('SaveMP3')); |
|
259 | + $defaults = array(); |
|
260 | + $defaults['lang'] = $selected_language; |
|
261 | + $form->setDefaults($defaults); |
|
262 | + $form->display(); |
|
263 | + echo '</div>'; |
|
264 | + |
|
265 | + ?> |
|
266 | 266 | |
267 | 267 | <!-- javascript form name form2 update voices --> |
268 | 268 | <script type="text/javascript"> |
@@ -307,43 +307,43 @@ discard block |
||
307 | 307 | { |
308 | 308 | $location='create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&dt2a=google'; |
309 | 309 | |
310 | - //security |
|
311 | - if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
312 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
313 | - return; |
|
314 | - } |
|
310 | + //security |
|
311 | + if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
312 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
313 | + return; |
|
314 | + } |
|
315 | 315 | |
316 | - $_course = api_get_course_info(); |
|
317 | - $_user = api_get_user_info(); |
|
316 | + $_course = api_get_course_info(); |
|
317 | + $_user = api_get_user_info(); |
|
318 | 318 | |
319 | - $clean_title=trim($_POST['title']); |
|
320 | - $clean_text=trim($_POST['text']); |
|
321 | - if(empty($clean_title) || empty($clean_text)){ |
|
322 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
323 | - return; |
|
324 | - } |
|
325 | - $clean_title = Security::remove_XSS($clean_title); |
|
326 | - $clean_title = Database::escape_string($clean_title); |
|
327 | - $clean_title = str_replace(' ', '_', $clean_title);//compound file names |
|
328 | - |
|
329 | - $clean_text = Security::remove_XSS($clean_text); |
|
330 | - $clean_lang = Security::remove_XSS($_POST['lang']); |
|
331 | - |
|
332 | - $extension='mp3'; |
|
333 | - $audio_filename=$clean_title.'.'.$extension; |
|
334 | - $audio_title = str_replace('_',' ',$clean_title); |
|
335 | - |
|
336 | - //prevent duplicates |
|
337 | - if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
338 | - $i = 1; |
|
339 | - while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
340 | - $audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
341 | - $audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
342 | - $audio_title = str_replace('_',' ',$audio_title); |
|
343 | - } |
|
319 | + $clean_title=trim($_POST['title']); |
|
320 | + $clean_text=trim($_POST['text']); |
|
321 | + if(empty($clean_title) || empty($clean_text)){ |
|
322 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
323 | + return; |
|
324 | + } |
|
325 | + $clean_title = Security::remove_XSS($clean_title); |
|
326 | + $clean_title = Database::escape_string($clean_title); |
|
327 | + $clean_title = str_replace(' ', '_', $clean_title);//compound file names |
|
328 | + |
|
329 | + $clean_text = Security::remove_XSS($clean_text); |
|
330 | + $clean_lang = Security::remove_XSS($_POST['lang']); |
|
331 | + |
|
332 | + $extension='mp3'; |
|
333 | + $audio_filename=$clean_title.'.'.$extension; |
|
334 | + $audio_title = str_replace('_',' ',$clean_title); |
|
335 | + |
|
336 | + //prevent duplicates |
|
337 | + if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
338 | + $i = 1; |
|
339 | + while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
340 | + $audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
341 | + $audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
342 | + $audio_title = str_replace('_',' ',$audio_title); |
|
343 | + } |
|
344 | 344 | |
345 | - $documentPath = $filepath.'/'.$audio_filename; |
|
346 | - /* |
|
345 | + $documentPath = $filepath.'/'.$audio_filename; |
|
346 | + /* |
|
347 | 347 | |
348 | 348 | //prev for a fine unicode, borrowed from main api TODO:clean |
349 | 349 | // Safe replacements for some non-letter characters (whitout blank spaces) |
@@ -358,52 +358,52 @@ discard block |
||
358 | 358 | $filename = api_transliterate($filename, 'x', $encoding); |
359 | 359 | // Replacing remaining dangerous non-letter characters. |
360 | 360 | $clean_text = str_replace($search, $replace, $filename);*/ |
361 | - $clean_text = api_replace_dangerous_char($clean_text); |
|
361 | + $clean_text = api_replace_dangerous_char($clean_text); |
|
362 | 362 | |
363 | - // adding the file |
|
364 | - // add new file to disk |
|
363 | + // adding the file |
|
364 | + // add new file to disk |
|
365 | 365 | |
366 | - $proxySettings = api_get_configuration_value('proxy_settings'); |
|
367 | - $url = "http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text).""; |
|
366 | + $proxySettings = api_get_configuration_value('proxy_settings'); |
|
367 | + $url = "http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text).""; |
|
368 | 368 | |
369 | - if (empty($proxySettings)) { |
|
370 | - $content = file_get_contents($url); |
|
371 | - } else { |
|
372 | - $context = stream_context_create($proxySettings); |
|
373 | - $content = file_get_contents($url, false, $context); |
|
374 | - } |
|
369 | + if (empty($proxySettings)) { |
|
370 | + $content = file_get_contents($url); |
|
371 | + } else { |
|
372 | + $context = stream_context_create($proxySettings); |
|
373 | + $content = file_get_contents($url, false, $context); |
|
374 | + } |
|
375 | 375 | |
376 | 376 | file_put_contents( |
377 | 377 | $documentPath, |
378 | 378 | $content |
379 | 379 | ); |
380 | 380 | |
381 | - // add document to database |
|
382 | - $current_session_id = api_get_session_id(); |
|
383 | - $groupId = api_get_group_id(); |
|
384 | - $relativeUrlPath=$dir; |
|
385 | - $doc_id = add_document( |
|
386 | - $_course, |
|
387 | - $relativeUrlPath.$audio_filename, |
|
388 | - 'file', |
|
389 | - filesize($documentPath), |
|
390 | - $audio_title |
|
391 | - ); |
|
392 | - api_item_property_update( |
|
393 | - $_course, |
|
394 | - TOOL_DOCUMENT, |
|
395 | - $doc_id, |
|
396 | - 'DocumentAdded', |
|
397 | - $_user['user_id'], |
|
398 | - $groupId, |
|
399 | - null, |
|
400 | - null, |
|
401 | - null, |
|
402 | - $current_session_id |
|
403 | - ); |
|
404 | - Display::display_confirmation_message(get_lang('DocumentCreated')); |
|
405 | - //return to location |
|
406 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
381 | + // add document to database |
|
382 | + $current_session_id = api_get_session_id(); |
|
383 | + $groupId = api_get_group_id(); |
|
384 | + $relativeUrlPath=$dir; |
|
385 | + $doc_id = add_document( |
|
386 | + $_course, |
|
387 | + $relativeUrlPath.$audio_filename, |
|
388 | + 'file', |
|
389 | + filesize($documentPath), |
|
390 | + $audio_title |
|
391 | + ); |
|
392 | + api_item_property_update( |
|
393 | + $_course, |
|
394 | + TOOL_DOCUMENT, |
|
395 | + $doc_id, |
|
396 | + 'DocumentAdded', |
|
397 | + $_user['user_id'], |
|
398 | + $groupId, |
|
399 | + null, |
|
400 | + null, |
|
401 | + null, |
|
402 | + $current_session_id |
|
403 | + ); |
|
404 | + Display::display_confirmation_message(get_lang('DocumentCreated')); |
|
405 | + //return to location |
|
406 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -416,45 +416,45 @@ discard block |
||
416 | 416 | */ |
417 | 417 | function downloadMP3_pediaphon($filepath, $dir) |
418 | 418 | { |
419 | - $location='create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&dt2a=pediaphon'; |
|
420 | - //security |
|
421 | - if(!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
422 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
423 | - return; |
|
424 | - } |
|
425 | - $_course = api_get_course_info(); |
|
426 | - $_user = api_get_user_info(); |
|
427 | - $clean_title=trim($_POST['title']); |
|
428 | - $clean_title= Database::escape_string($clean_title); |
|
429 | - $clean_text=trim($_POST['text']); |
|
430 | - $clean_voices=Security::remove_XSS($_POST['voices']); |
|
431 | - if(empty($clean_title) || empty($clean_text) || empty($clean_voices)){ |
|
432 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
433 | - return; |
|
434 | - } |
|
435 | - $clean_title = Security::remove_XSS($clean_title); |
|
436 | - $clean_title = Database::escape_string($clean_title); |
|
437 | - $clean_title = str_replace(' ', '_', $clean_title);//compound file names |
|
438 | - $clean_text = Security::remove_XSS($clean_text); |
|
439 | - $clean_lang = Security::remove_XSS($_POST['lang']); |
|
440 | - $clean_speed = Security::remove_XSS($_POST['speed']); |
|
441 | - |
|
442 | - $extension='mp3'; |
|
443 | - $audio_filename=$clean_title.'.'.$extension; |
|
444 | - $audio_title = str_replace('_',' ',$clean_title); |
|
445 | - |
|
446 | - //prevent duplicates |
|
447 | - if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
448 | - $i = 1; |
|
449 | - while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
450 | - $audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
451 | - $audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
452 | - $audio_title = str_replace('_',' ',$audio_title); |
|
453 | - } |
|
419 | + $location='create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&dt2a=pediaphon'; |
|
420 | + //security |
|
421 | + if(!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
422 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
423 | + return; |
|
424 | + } |
|
425 | + $_course = api_get_course_info(); |
|
426 | + $_user = api_get_user_info(); |
|
427 | + $clean_title=trim($_POST['title']); |
|
428 | + $clean_title= Database::escape_string($clean_title); |
|
429 | + $clean_text=trim($_POST['text']); |
|
430 | + $clean_voices=Security::remove_XSS($_POST['voices']); |
|
431 | + if(empty($clean_title) || empty($clean_text) || empty($clean_voices)){ |
|
432 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
433 | + return; |
|
434 | + } |
|
435 | + $clean_title = Security::remove_XSS($clean_title); |
|
436 | + $clean_title = Database::escape_string($clean_title); |
|
437 | + $clean_title = str_replace(' ', '_', $clean_title);//compound file names |
|
438 | + $clean_text = Security::remove_XSS($clean_text); |
|
439 | + $clean_lang = Security::remove_XSS($_POST['lang']); |
|
440 | + $clean_speed = Security::remove_XSS($_POST['speed']); |
|
441 | + |
|
442 | + $extension='mp3'; |
|
443 | + $audio_filename=$clean_title.'.'.$extension; |
|
444 | + $audio_title = str_replace('_',' ',$clean_title); |
|
445 | + |
|
446 | + //prevent duplicates |
|
447 | + if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
448 | + $i = 1; |
|
449 | + while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
450 | + $audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
451 | + $audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
452 | + $audio_title = str_replace('_',' ',$audio_title); |
|
453 | + } |
|
454 | 454 | |
455 | - $documentPath = $filepath.'/'.$audio_filename; |
|
455 | + $documentPath = $filepath.'/'.$audio_filename; |
|
456 | 456 | |
457 | - /*//prev for a fine unicode, borrowed from main api TODO:clean |
|
457 | + /*//prev for a fine unicode, borrowed from main api TODO:clean |
|
458 | 458 | // Safe replacements for some non-letter characters (whitout blank spaces) |
459 | 459 | $search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%'); |
460 | 460 | $replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); |
@@ -467,48 +467,48 @@ discard block |
||
467 | 467 | $filename = api_transliterate($filename, 'x', $encoding); |
468 | 468 | // Replacing remaining dangerous non-letter characters. |
469 | 469 | $clean_text = str_replace($search, $replace, $filename);*/ |
470 | - $clean_text = api_replace_dangerous_char($clean_text); |
|
470 | + $clean_text = api_replace_dangerous_char($clean_text); |
|
471 | 471 | |
472 | - //adding the file |
|
472 | + //adding the file |
|
473 | 473 | |
474 | - if ($clean_lang=='de') { |
|
475 | - $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi'; |
|
476 | - $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/'; |
|
477 | - } else { |
|
478 | - $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi';//en, es, fr |
|
479 | - $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/'; |
|
480 | - } |
|
474 | + if ($clean_lang=='de') { |
|
475 | + $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi'; |
|
476 | + $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/'; |
|
477 | + } else { |
|
478 | + $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi';//en, es, fr |
|
479 | + $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/'; |
|
480 | + } |
|
481 | 481 | |
482 | - $data="stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak"; |
|
483 | - $opts = array('http' => |
|
484 | - array( |
|
485 | - 'method' => 'POST', |
|
486 | - 'header' =>"Content-Type: application/x-www-form-urlencoded\r\n", |
|
487 | - "Content-Length: " . strlen($data) . "\r\n", |
|
488 | - 'content' => $data |
|
489 | - ) |
|
490 | - ); |
|
491 | - $context = stream_context_create($opts); |
|
492 | - // Download the whole HTML page |
|
493 | - $previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); |
|
494 | - |
|
495 | - //extract the audio file path |
|
496 | - $search_source = preg_match($find_t2v, $previous_returntext2voice, $hits); |
|
497 | - $souce_end = substr($hits[0], 0, -1); |
|
498 | - //download file |
|
499 | - $returntext2voice = file_get_contents($souce_end); |
|
500 | - //save file |
|
501 | - $f = @file_put_contents($documentPath, $returntext2voice); |
|
502 | - if ($f === false && !empty($php_errormsg)) { |
|
482 | + $data="stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak"; |
|
483 | + $opts = array('http' => |
|
484 | + array( |
|
485 | + 'method' => 'POST', |
|
486 | + 'header' =>"Content-Type: application/x-www-form-urlencoded\r\n", |
|
487 | + "Content-Length: " . strlen($data) . "\r\n", |
|
488 | + 'content' => $data |
|
489 | + ) |
|
490 | + ); |
|
491 | + $context = stream_context_create($opts); |
|
492 | + // Download the whole HTML page |
|
493 | + $previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); |
|
494 | + |
|
495 | + //extract the audio file path |
|
496 | + $search_source = preg_match($find_t2v, $previous_returntext2voice, $hits); |
|
497 | + $souce_end = substr($hits[0], 0, -1); |
|
498 | + //download file |
|
499 | + $returntext2voice = file_get_contents($souce_end); |
|
500 | + //save file |
|
501 | + $f = @file_put_contents($documentPath, $returntext2voice); |
|
502 | + if ($f === false && !empty($php_errormsg)) { |
|
503 | 503 | error_log($php_errormsg); |
504 | 504 | } |
505 | - //add document to database |
|
506 | - $current_session_id = api_get_session_id(); |
|
507 | - $groupId = api_get_group_id(); |
|
508 | - $relativeUrlPath=$dir; |
|
509 | - $doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); |
|
510 | - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
505 | + //add document to database |
|
506 | + $current_session_id = api_get_session_id(); |
|
507 | + $groupId = api_get_group_id(); |
|
508 | + $relativeUrlPath=$dir; |
|
509 | + $doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); |
|
510 | + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); |
|
511 | 511 | Display::display_confirmation_message(get_lang('DocumentCreated')); |
512 | - //return to location |
|
513 | - echo '<script>window.location.href="'.$location.'"</script>'; |
|
512 | + //return to location |
|
513 | + echo '<script>window.location.href="'.$location.'"</script>'; |
|
514 | 514 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); |
93 | 93 | |
94 | 94 | if (empty($objExercise)) { |
95 | - $objExercise = new Exercise(); |
|
95 | + $objExercise = new Exercise(); |
|
96 | 96 | $objExercise->read($exercise_id); |
97 | 97 | } |
98 | 98 | $feedback_type = $objExercise->feedback_type; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | //Only users can see their own results |
101 | 101 | if (!$is_allowedToEdit) { |
102 | 102 | if ($student_id != $current_user_id) { |
103 | - api_not_allowed(true); |
|
103 | + api_not_allowed(true); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | if (isset($_SESSION['gradebook'])) { |
108 | - $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
108 | + $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!empty($gradebook) && $gradebook=='view') { |
112 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
112 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $fromlink = ''; |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
125 | 125 | |
126 | 126 | if ($origin != 'learnpath') { |
127 | - Display::display_header(''); |
|
127 | + Display::display_header(''); |
|
128 | 128 | } else { |
129 | 129 | $htmlHeadXtra[] = " |
130 | 130 | <style> |
131 | 131 | body { background: none;} |
132 | 132 | </style> |
133 | 133 | "; |
134 | - Display::display_reduced_header(); |
|
134 | + Display::display_reduced_header(); |
|
135 | 135 | } |
136 | 136 | ?> |
137 | 137 | <script> |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | } else { |
213 | - Display::display_warning_message(get_lang('CantViewResults')); |
|
214 | - $show_results = false; |
|
213 | + Display::display_warning_message(get_lang('CantViewResults')); |
|
214 | + $show_results = false; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) { |
218 | - $show_results = false; |
|
218 | + $show_results = false; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if ($show_results || $show_only_total_score) { |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | $exerciseResult = array(); |
264 | 264 | |
265 | 265 | while ($row = Database::fetch_array($result)) { |
266 | - $question_list_from_database[] = $row['question_id']; |
|
267 | - $exerciseResult[$row['question_id']] = $row['answer']; |
|
266 | + $question_list_from_database[] = $row['question_id']; |
|
267 | + $exerciseResult[$row['question_id']] = $row['answer']; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | //Fixing #2073 Fixing order of questions |
271 | 271 | if (!empty($track_exercise_info['data_tracking'])) { |
272 | - $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
272 | + $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
273 | 273 | |
274 | 274 | // Getting question list from data_tracking |
275 | 275 | if (!empty($temp_question_list)) { |
@@ -309,23 +309,23 @@ discard block |
||
309 | 309 | |
310 | 310 | foreach ($questionList as $questionId) { |
311 | 311 | |
312 | - $choice = $exerciseResult[$questionId]; |
|
313 | - // destruction of the Question object |
|
314 | - unset($objQuestionTmp); |
|
312 | + $choice = $exerciseResult[$questionId]; |
|
313 | + // destruction of the Question object |
|
314 | + unset($objQuestionTmp); |
|
315 | 315 | |
316 | - // creates a temporary Question object |
|
317 | - $objQuestionTmp = Question::read($questionId); |
|
318 | - $questionWeighting = $objQuestionTmp->selectWeighting(); |
|
319 | - $answerType = $objQuestionTmp->selectType(); |
|
316 | + // creates a temporary Question object |
|
317 | + $objQuestionTmp = Question::read($questionId); |
|
318 | + $questionWeighting = $objQuestionTmp->selectWeighting(); |
|
319 | + $answerType = $objQuestionTmp->selectType(); |
|
320 | 320 | |
321 | - // Start buffer |
|
321 | + // Start buffer |
|
322 | 322 | ob_start(); |
323 | 323 | |
324 | 324 | /* Use switch |
325 | 325 | switch ($answerType) { |
326 | 326 | }*/ |
327 | 327 | |
328 | - if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
328 | + if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
329 | 329 | $question_result = $objExercise->manage_answer( |
330 | 330 | $id, |
331 | 331 | $questionId, |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | ); |
442 | 442 | $questionScore = $question_result['score']; |
443 | 443 | $totalScore += $question_result['score']; |
444 | - } elseif ($answerType == HOT_SPOT) { |
|
445 | - if ($show_results) { |
|
446 | - echo '<table width="500" border="0"><tr> |
|
444 | + } elseif ($answerType == HOT_SPOT) { |
|
445 | + if ($show_results) { |
|
446 | + echo '<table width="500" border="0"><tr> |
|
447 | 447 | <td valign="top" align="center" style="padding-left:0px;" > |
448 | 448 | <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">'; |
449 | - } |
|
449 | + } |
|
450 | 450 | $question_result = $objExercise->manage_answer( |
451 | 451 | $id, |
452 | 452 | $questionId, |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | <br> |
486 | 486 | "; |
487 | 487 | } |
488 | - } else if($answerType == HOT_SPOT_DELINEATION) { |
|
488 | + } else if($answerType == HOT_SPOT_DELINEATION) { |
|
489 | 489 | |
490 | 490 | $question_result = $objExercise->manage_answer( |
491 | 491 | $id, |
@@ -639,15 +639,15 @@ discard block |
||
639 | 639 | </table> |
640 | 640 | "; |
641 | 641 | } |
642 | - } |
|
642 | + } |
|
643 | 643 | |
644 | - if ($show_results) { |
|
645 | - if ($answerType != HOT_SPOT) { |
|
646 | - echo '</table>'; |
|
647 | - } |
|
648 | - } |
|
644 | + if ($show_results) { |
|
645 | + if ($answerType != HOT_SPOT) { |
|
646 | + echo '</table>'; |
|
647 | + } |
|
648 | + } |
|
649 | 649 | |
650 | - $comnt = null; |
|
650 | + $comnt = null; |
|
651 | 651 | |
652 | 652 | if ($show_results) { |
653 | 653 | if ( |
@@ -664,40 +664,40 @@ discard block |
||
664 | 664 | |
665 | 665 | $marksname = ''; |
666 | 666 | |
667 | - if ($isFeedbackAllowed) { |
|
668 | - $name = "fckdiv".$questionId; |
|
669 | - $marksname = "marksName".$questionId; |
|
670 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
671 | - $url_name = get_lang('EditCommentsAndMarks'); |
|
672 | - } else { |
|
673 | - if ($action=='edit') { |
|
674 | - $url_name = get_lang('EditIndividualComment'); |
|
675 | - } else { |
|
676 | - $url_name = get_lang('AddComments'); |
|
677 | - } |
|
678 | - } |
|
667 | + if ($isFeedbackAllowed) { |
|
668 | + $name = "fckdiv".$questionId; |
|
669 | + $marksname = "marksName".$questionId; |
|
670 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
671 | + $url_name = get_lang('EditCommentsAndMarks'); |
|
672 | + } else { |
|
673 | + if ($action=='edit') { |
|
674 | + $url_name = get_lang('EditIndividualComment'); |
|
675 | + } else { |
|
676 | + $url_name = get_lang('AddComments'); |
|
677 | + } |
|
678 | + } |
|
679 | 679 | echo '<br />'; |
680 | 680 | echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');")); |
681 | - echo '<br />'; |
|
681 | + echo '<br />'; |
|
682 | 682 | |
683 | 683 | echo '<div id="feedback_'.$name.'" style="width:100%">'; |
684 | - $comnt = trim(Event::get_comments($id, $questionId)); |
|
685 | - if (empty($comnt)) { |
|
686 | - echo '<br />'; |
|
687 | - } else { |
|
688 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
689 | - } |
|
690 | - echo '</div>'; |
|
684 | + $comnt = trim(Event::get_comments($id, $questionId)); |
|
685 | + if (empty($comnt)) { |
|
686 | + echo '<br />'; |
|
687 | + } else { |
|
688 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
689 | + } |
|
690 | + echo '</div>'; |
|
691 | 691 | |
692 | 692 | echo '<div id="'.$name.'" style="display:none">'; |
693 | - $arrid[] = $questionId; |
|
694 | - $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
695 | - $feedback_form->addElement('html','<br>'); |
|
696 | - $renderer =& $feedback_form->defaultRenderer(); |
|
697 | - $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
698 | - $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
699 | - $comnt = Event::get_comments($id, $questionId); |
|
700 | - $default = array('comments_'.$questionId => $comnt); |
|
693 | + $arrid[] = $questionId; |
|
694 | + $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
695 | + $feedback_form->addElement('html','<br>'); |
|
696 | + $renderer =& $feedback_form->defaultRenderer(); |
|
697 | + $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
698 | + $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
699 | + $comnt = Event::get_comments($id, $questionId); |
|
700 | + $default = array('comments_'.$questionId => $comnt); |
|
701 | 701 | |
702 | 702 | if ($useAdvancedEditor) { |
703 | 703 | $feedback_form->addElement( |
@@ -714,52 +714,52 @@ discard block |
||
714 | 714 | } else { |
715 | 715 | $feedback_form->addElement('textarea', 'comments_' . $questionId); |
716 | 716 | } |
717 | - $feedback_form->addElement('html','<br>'); |
|
718 | - $feedback_form->setDefaults($default); |
|
719 | - $feedback_form->display(); |
|
720 | - echo '</div>'; |
|
721 | - |
|
722 | - } else { |
|
723 | - $comnt = Event::get_comments($id, $questionId); |
|
724 | - echo '<br />'; |
|
725 | - if (!empty($comnt)) { |
|
726 | - echo '<b>'.get_lang('Feedback').'</b>'; |
|
727 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
728 | - } |
|
729 | - } |
|
730 | - |
|
731 | - if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
732 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
733 | - $marksname = "marksName".$questionId; |
|
717 | + $feedback_form->addElement('html','<br>'); |
|
718 | + $feedback_form->setDefaults($default); |
|
719 | + $feedback_form->display(); |
|
720 | + echo '</div>'; |
|
721 | + |
|
722 | + } else { |
|
723 | + $comnt = Event::get_comments($id, $questionId); |
|
724 | + echo '<br />'; |
|
725 | + if (!empty($comnt)) { |
|
726 | + echo '<b>'.get_lang('Feedback').'</b>'; |
|
727 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
728 | + } |
|
729 | + } |
|
730 | + |
|
731 | + if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
732 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
733 | + $marksname = "marksName".$questionId; |
|
734 | 734 | echo '<div id="'.$marksname.'" style="display:none">'; |
735 | 735 | echo '<form name="marksform_'.$questionId.'" method="post" action="">'; |
736 | - $arrmarks[] = $questionId; |
|
737 | - echo get_lang("AssignMarks"); |
|
738 | - echo " <select name='marks' id='marks'>"; |
|
739 | - for ($i=0;$i<=$questionWeighting;$i++) { |
|
740 | - echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
741 | - } |
|
742 | - echo '</select>'; |
|
743 | - echo '</form><br /></div>'; |
|
744 | - |
|
745 | - if ($questionScore == -1 ) { |
|
746 | - $questionScore = 0; |
|
747 | - echo Display::return_message(get_lang('notCorrectedYet')); |
|
748 | - } |
|
749 | - } else { |
|
750 | - $arrmarks[] = $questionId; |
|
751 | - echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
736 | + $arrmarks[] = $questionId; |
|
737 | + echo get_lang("AssignMarks"); |
|
738 | + echo " <select name='marks' id='marks'>"; |
|
739 | + for ($i=0;$i<=$questionWeighting;$i++) { |
|
740 | + echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
741 | + } |
|
742 | + echo '</select>'; |
|
743 | + echo '</form><br /></div>'; |
|
744 | + |
|
745 | + if ($questionScore == -1 ) { |
|
746 | + $questionScore = 0; |
|
747 | + echo Display::return_message(get_lang('notCorrectedYet')); |
|
748 | + } |
|
749 | + } else { |
|
750 | + $arrmarks[] = $questionId; |
|
751 | + echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
752 | 752 | <select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>'; |
753 | - } |
|
754 | - } else { |
|
755 | - if ($questionScore == -1) { |
|
756 | - $questionScore = 0; |
|
757 | - } |
|
758 | - } |
|
759 | - } |
|
753 | + } |
|
754 | + } else { |
|
755 | + if ($questionScore == -1) { |
|
756 | + $questionScore = 0; |
|
757 | + } |
|
758 | + } |
|
759 | + } |
|
760 | 760 | |
761 | 761 | $my_total_score = $questionScore; |
762 | - $my_total_weight = $questionWeighting; |
|
762 | + $my_total_weight = $questionWeighting; |
|
763 | 763 | $totalWeighting += $questionWeighting; |
764 | 764 | $category_was_added_for_this_test = false; |
765 | 765 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | |
806 | 806 | $score = array(); |
807 | 807 | if ($show_results) { |
808 | - $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
808 | + $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
809 | 809 | $score['pass'] = $my_total_score >= $my_total_weight ? true : false; |
810 | 810 | $score['type'] = $answerType; |
811 | 811 | $score['score'] = $my_total_score; |
@@ -813,18 +813,18 @@ discard block |
||
813 | 813 | $score['comments'] = isset($comnt) ? $comnt : null; |
814 | 814 | } |
815 | 815 | |
816 | - unset($objAnswerTmp); |
|
817 | - $i++; |
|
816 | + unset($objAnswerTmp); |
|
817 | + $i++; |
|
818 | 818 | |
819 | 819 | $contents = ob_get_clean(); |
820 | 820 | |
821 | 821 | $question_content = '<div class="question_row">'; |
822 | 822 | |
823 | - if ($show_results) { |
|
823 | + if ($show_results) { |
|
824 | 824 | //Shows question title an description |
825 | - $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
826 | - } |
|
827 | - $counter++; |
|
825 | + $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
826 | + } |
|
827 | + $counter++; |
|
828 | 828 | $question_content .= $contents; |
829 | 829 | $question_content .= '</div>'; |
830 | 830 | $exercise_content .= $question_content; |
@@ -834,12 +834,12 @@ discard block |
||
834 | 834 | |
835 | 835 | //Total score |
836 | 836 | if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { |
837 | - if ($show_results || $show_only_total_score) { |
|
837 | + if ($show_results || $show_only_total_score) { |
|
838 | 838 | $total_score_text .= '<div class="question_row">'; |
839 | 839 | $my_total_score_temp = $totalScore; |
840 | - if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
841 | - $my_total_score_temp = 0; |
|
842 | - } |
|
840 | + if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
841 | + $my_total_score_temp = 0; |
|
842 | + } |
|
843 | 843 | $total_score_text .= ExerciseLib::get_question_ribbon( |
844 | 844 | $objExercise, |
845 | 845 | $my_total_score_temp, |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | true |
848 | 848 | ); |
849 | 849 | $total_score_text .= '</div>'; |
850 | - } |
|
850 | + } |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | if (!empty($category_list) && ($show_results || $show_only_total_score)) { |
@@ -871,26 +871,26 @@ discard block |
||
871 | 871 | } |
872 | 872 | |
873 | 873 | if ($isFeedbackAllowed) { |
874 | - if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
875 | - echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
876 | - echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
877 | - echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
878 | - echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
879 | - echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
880 | - echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
881 | - } else { |
|
882 | - echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
883 | - } |
|
884 | - if ($origin !='learnpath' && $origin!='student_progress') { |
|
874 | + if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
875 | + echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
876 | + echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
877 | + echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
878 | + echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
879 | + echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
880 | + echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
881 | + } else { |
|
882 | + echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
883 | + } |
|
884 | + if ($origin !='learnpath' && $origin!='student_progress') { |
|
885 | 885 | echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>'; |
886 | - ?> |
|
886 | + ?> |
|
887 | 887 | <br /> |
888 | 888 | <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"> |
889 | 889 | <?php echo get_lang('CorrectTest'); ?> |
890 | 890 | </button> |
891 | 891 | </form> |
892 | 892 | <?php |
893 | - } |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | //Came from lpstats in a lp |
@@ -907,21 +907,21 @@ discard block |
||
907 | 907 | } |
908 | 908 | |
909 | 909 | if ($origin != 'learnpath') { |
910 | - //we are not in learnpath tool |
|
911 | - Display::display_footer(); |
|
910 | + //we are not in learnpath tool |
|
911 | + Display::display_footer(); |
|
912 | 912 | } else { |
913 | - if (!isset($_GET['fb_type'])) { |
|
914 | - $lp_mode = $_SESSION['lp_mode']; |
|
915 | - $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
916 | - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
917 | - echo '<script type="text/javascript">'.$href.'</script>'; |
|
918 | - // Record the results in the learning path, using the SCORM interface (API) |
|
919 | - echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
920 | - echo '</body></html>'; |
|
921 | - } else { |
|
922 | - Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
913 | + if (!isset($_GET['fb_type'])) { |
|
914 | + $lp_mode = $_SESSION['lp_mode']; |
|
915 | + $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
916 | + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
917 | + echo '<script type="text/javascript">'.$href.'</script>'; |
|
918 | + // Record the results in the learning path, using the SCORM interface (API) |
|
919 | + echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
920 | + echo '</body></html>'; |
|
921 | + } else { |
|
922 | + Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
923 | 923 | echo '<br />'; |
924 | - } |
|
924 | + } |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | // Destroying the session |