@@ -212,7 +212,7 @@ |
||
| 212 | 212 | * @param array $arr1 first array |
| 213 | 213 | * @param array $arr2 second array |
| 214 | 214 | * |
| 215 | - * @return array difference between the two arrays |
|
| 215 | + * @return string difference between the two arrays |
|
| 216 | 216 | */ |
| 217 | 217 | function diff($arr1, $arr2) |
| 218 | 218 | { |
@@ -1212,6 +1212,7 @@ |
||
| 1212 | 1212 | * Restore a forum-post |
| 1213 | 1213 | * @TODO Restore tree-structure of posts. For example: attachments to posts. |
| 1214 | 1214 | * @param false|string $topic_id |
| 1215 | + * @param false|string $forum_id |
|
| 1215 | 1216 | */ |
| 1216 | 1217 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
| 1217 | 1218 | { |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | class CourseRestorer |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | - * The course-object |
|
| 28 | - */ |
|
| 27 | + * The course-object |
|
| 28 | + */ |
|
| 29 | 29 | public $course; |
| 30 | 30 | public $destination_course_info; |
| 31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'events', |
| 45 | 45 | 'forum_category', |
| 46 | 46 | 'forums', |
| 47 | - // 'forum_topics', |
|
| 47 | + // 'forum_topics', |
|
| 48 | 48 | 'glossary', |
| 49 | 49 | 'quizzes', |
| 50 | 50 | 'test_category', |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | $this->tool_copy_settings = $array; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Restore a course. |
|
| 115 | + /** |
|
| 116 | + * Restore a course. |
|
| 117 | 117 | * |
| 118 | - * @param string $destination_course_code code of the Chamilo-course in |
|
| 119 | - * @param int $session_id |
|
| 120 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
| 118 | + * @param string $destination_course_code code of the Chamilo-course in |
|
| 119 | + * @param int $session_id |
|
| 120 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
| 121 | 121 | * @param bool $respect_base_content |
| 122 | 122 | * @return false|null |
| 123 | - */ |
|
| 123 | + */ |
|
| 124 | 124 | public function restore( |
| 125 | 125 | $destination_course_code = '', |
| 126 | 126 | $session_id = 0, |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Restore only harmless course settings: |
|
| 239 | + /** |
|
| 240 | + * Restore only harmless course settings: |
|
| 241 | 241 | * course_language, visibility, department_name,department_url, |
| 242 | 242 | * subscribe, unsubscribe ,category_code |
| 243 | - * |
|
| 244 | - * @param string $destination_course_code |
|
| 245 | - */ |
|
| 243 | + * |
|
| 244 | + * @param string $destination_course_code |
|
| 245 | + */ |
|
| 246 | 246 | public function restore_course_settings($destination_course_code) |
| 247 | 247 | { |
| 248 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
| 249 | - $course_info = $this->course->info; |
|
| 248 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
| 249 | + $course_info = $this->course->info; |
|
| 250 | 250 | $params['course_language'] = $course_info['language']; |
| 251 | 251 | $params['visibility'] = $course_info['visibility']; |
| 252 | 252 | $params['department_name'] = $course_info['department_name']; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $params['subscribe'] = $course_info['subscribe_allowed']; |
| 257 | 257 | $params['unsubscribe'] = $course_info['unsubscribe']; |
| 258 | 258 | CourseManager::update_attributes($origin_course_info['real_id'], $params); |
| 259 | - } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * Restore documents |
@@ -922,56 +922,56 @@ discard block |
||
| 922 | 922 | unset($_SESSION['new_base_foldername']); |
| 923 | 923 | unset($_SESSION['orig_base_foldername']); |
| 924 | 924 | unset($_SESSION['new_base_path']); |
| 925 | - } |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | - /** |
|
| 928 | - * Restore scorm documents |
|
| 929 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
| 927 | + /** |
|
| 928 | + * Restore scorm documents |
|
| 929 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
| 930 | 930 | * see #7029 |
| 931 | - */ |
|
| 932 | - public function restore_scorm_documents() |
|
| 931 | + */ |
|
| 932 | + public function restore_scorm_documents() |
|
| 933 | 933 | { |
| 934 | - $perm = api_get_permissions_for_new_directories(); |
|
| 934 | + $perm = api_get_permissions_for_new_directories(); |
|
| 935 | 935 | |
| 936 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
| 937 | - $resources = $this->course->resources; |
|
| 936 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
| 937 | + $resources = $this->course->resources; |
|
| 938 | 938 | |
| 939 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
| 940 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
| 941 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
| 939 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
| 940 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
| 941 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
| 942 | 942 | |
| 943 | - if (file_exists($path.$document->path)) { |
|
| 944 | - switch ($this->file_option) { |
|
| 945 | - case FILE_OVERWRITE: |
|
| 946 | - rmdirr($path.$document->path); |
|
| 943 | + if (file_exists($path.$document->path)) { |
|
| 944 | + switch ($this->file_option) { |
|
| 945 | + case FILE_OVERWRITE: |
|
| 946 | + rmdirr($path.$document->path); |
|
| 947 | 947 | copyDirTo( |
| 948 | 948 | $this->course->backup_path . '/' . $document->path, |
| 949 | 949 | $path . dirname($document->path), |
| 950 | 950 | false |
| 951 | 951 | ); |
| 952 | - break; |
|
| 953 | - case FILE_SKIP: |
|
| 954 | - break; |
|
| 952 | + break; |
|
| 953 | + case FILE_SKIP: |
|
| 954 | + break; |
|
| 955 | 955 | case FILE_RENAME: |
| 956 | - $i = 1; |
|
| 957 | - $ext = explode('.', basename($document->path)); |
|
| 958 | - if (count($ext) > 1) { |
|
| 959 | - $ext = array_pop($ext); |
|
| 960 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 961 | - $ext = '.'.$ext; |
|
| 962 | - } else { |
|
| 963 | - $ext = ''; |
|
| 964 | - $file_name_no_ext = $document->path; |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 968 | - $file_exists = file_exists($path.$new_file_name); |
|
| 969 | - |
|
| 970 | - while ($file_exists) { |
|
| 971 | - $i ++; |
|
| 972 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 973 | - $file_exists = file_exists($path.$new_file_name); |
|
| 974 | - } |
|
| 956 | + $i = 1; |
|
| 957 | + $ext = explode('.', basename($document->path)); |
|
| 958 | + if (count($ext) > 1) { |
|
| 959 | + $ext = array_pop($ext); |
|
| 960 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
| 961 | + $ext = '.'.$ext; |
|
| 962 | + } else { |
|
| 963 | + $ext = ''; |
|
| 964 | + $file_name_no_ext = $document->path; |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 968 | + $file_exists = file_exists($path.$new_file_name); |
|
| 969 | + |
|
| 970 | + while ($file_exists) { |
|
| 971 | + $i ++; |
|
| 972 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
| 973 | + $file_exists = file_exists($path.$new_file_name); |
|
| 974 | + } |
|
| 975 | 975 | |
| 976 | 976 | rename( |
| 977 | 977 | $this->course->backup_path . '/' . $document->path, |
@@ -987,32 +987,32 @@ discard block |
||
| 987 | 987 | $this->course->backup_path . '/' . $document->path |
| 988 | 988 | ); |
| 989 | 989 | |
| 990 | - break; |
|
| 991 | - } // end switch |
|
| 992 | - } else { |
|
| 990 | + break; |
|
| 991 | + } // end switch |
|
| 992 | + } else { |
|
| 993 | 993 | // end if file exists |
| 994 | 994 | copyDirTo( |
| 995 | 995 | $this->course->backup_path . '/' . $document->path, |
| 996 | 996 | $path . dirname($document->path), |
| 997 | 997 | false |
| 998 | 998 | ); |
| 999 | - } |
|
| 1000 | - } // end for each |
|
| 1001 | - } |
|
| 1002 | - } |
|
| 999 | + } |
|
| 1000 | + } // end for each |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 1003 | 1003 | |
| 1004 | - /** |
|
| 1005 | - * Restore forums |
|
| 1004 | + /** |
|
| 1005 | + * Restore forums |
|
| 1006 | 1006 | * |
| 1007 | 1007 | * @param int $sessionId |
| 1008 | 1008 | */ |
| 1009 | - public function restore_forums($sessionId = 0) |
|
| 1009 | + public function restore_forums($sessionId = 0) |
|
| 1010 | 1010 | { |
| 1011 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
| 1011 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
| 1012 | 1012 | $sessionId = intval($sessionId); |
| 1013 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
| 1014 | - $resources = $this->course->resources; |
|
| 1015 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
| 1013 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
| 1014 | + $resources = $this->course->resources; |
|
| 1015 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
| 1016 | 1016 | $params = (array)$forum->obj; |
| 1017 | 1017 | $cat_id = ''; |
| 1018 | 1018 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1059,33 +1059,33 @@ discard block |
||
| 1059 | 1059 | Database::query($sql); |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
| 1063 | - |
|
| 1064 | - $forum_topics = 0; |
|
| 1065 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
| 1066 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
| 1067 | - if ($topic->obj->forum_id == $id) { |
|
| 1068 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
| 1069 | - $forum_topics ++; |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - } |
|
| 1073 | - if ($forum_topics > 0) { |
|
| 1074 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
| 1062 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
| 1063 | + |
|
| 1064 | + $forum_topics = 0; |
|
| 1065 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
| 1066 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
| 1067 | + if ($topic->obj->forum_id == $id) { |
|
| 1068 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
| 1069 | + $forum_topics ++; |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + } |
|
| 1073 | + if ($forum_topics > 0) { |
|
| 1074 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
| 1075 | 1075 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
| 1076 | - Database::query($sql); |
|
| 1077 | - } |
|
| 1078 | - } |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - /** |
|
| 1083 | - * Restore forum-categories |
|
| 1084 | - */ |
|
| 1076 | + Database::query($sql); |
|
| 1077 | + } |
|
| 1078 | + } |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + /** |
|
| 1083 | + * Restore forum-categories |
|
| 1084 | + */ |
|
| 1085 | 1085 | public function restore_forum_category($my_id = null, $sessionId = 0) |
| 1086 | 1086 | { |
| 1087 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
| 1088 | - $resources = $this->course->resources; |
|
| 1087 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
| 1088 | + $resources = $this->course->resources; |
|
| 1089 | 1089 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
| 1090 | 1090 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
| 1091 | 1091 | if (!empty($my_id)) { |
@@ -1123,16 +1123,16 @@ discard block |
||
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| 1125 | 1125 | } |
| 1126 | - } |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | - /** |
|
| 1129 | - * Restore a forum-topic |
|
| 1130 | - * @param false|string $forum_id |
|
| 1131 | - */ |
|
| 1128 | + /** |
|
| 1129 | + * Restore a forum-topic |
|
| 1130 | + * @param false|string $forum_id |
|
| 1131 | + */ |
|
| 1132 | 1132 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
| 1133 | 1133 | { |
| 1134 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 1135 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
| 1134 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 1135 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
| 1136 | 1136 | |
| 1137 | 1137 | $params = (array)$topic->obj; |
| 1138 | 1138 | $params = self::DBUTF8_array($params); |
@@ -1169,27 +1169,27 @@ discard block |
||
| 1169 | 1169 | $sessionId |
| 1170 | 1170 | ); |
| 1171 | 1171 | |
| 1172 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
| 1173 | - $topic_replies = -1; |
|
| 1174 | - |
|
| 1175 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
| 1176 | - if ($post->obj->thread_id == $thread_id) { |
|
| 1177 | - $topic_replies++; |
|
| 1178 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
| 1179 | - } |
|
| 1180 | - } |
|
| 1181 | - return $new_id; |
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - /** |
|
| 1185 | - * Restore a forum-post |
|
| 1186 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
| 1187 | - * @param false|string $topic_id |
|
| 1188 | - */ |
|
| 1172 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
| 1173 | + $topic_replies = -1; |
|
| 1174 | + |
|
| 1175 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
| 1176 | + if ($post->obj->thread_id == $thread_id) { |
|
| 1177 | + $topic_replies++; |
|
| 1178 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
| 1179 | + } |
|
| 1180 | + } |
|
| 1181 | + return $new_id; |
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + /** |
|
| 1185 | + * Restore a forum-post |
|
| 1186 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
| 1187 | + * @param false|string $topic_id |
|
| 1188 | + */ |
|
| 1189 | 1189 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
| 1190 | 1190 | { |
| 1191 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
| 1192 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
| 1191 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
| 1192 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
| 1193 | 1193 | $params = (array) $post->obj; |
| 1194 | 1194 | $params['c_id'] = $this->destination_course_id; |
| 1195 | 1195 | $params['forum_id'] = $forum_id; |
@@ -1225,37 +1225,37 @@ discard block |
||
| 1225 | 1225 | null, |
| 1226 | 1226 | $sessionId |
| 1227 | 1227 | ); |
| 1228 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
| 1228 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
| 1229 | 1229 | |
| 1230 | - return $new_id; |
|
| 1231 | - } |
|
| 1230 | + return $new_id; |
|
| 1231 | + } |
|
| 1232 | 1232 | |
| 1233 | - /** |
|
| 1234 | - * Restore links |
|
| 1235 | - */ |
|
| 1233 | + /** |
|
| 1234 | + * Restore links |
|
| 1235 | + */ |
|
| 1236 | 1236 | public function restore_links($session_id = 0) |
| 1237 | 1237 | { |
| 1238 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
| 1239 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
| 1240 | - $resources = $this->course->resources; |
|
| 1238 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
| 1239 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
| 1240 | + $resources = $this->course->resources; |
|
| 1241 | 1241 | |
| 1242 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
| 1242 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
| 1243 | 1243 | $cat_id = $this->restore_link_category( |
| 1244 | 1244 | $link->category_id, |
| 1245 | 1245 | $session_id |
| 1246 | 1246 | ); |
| 1247 | - $sql = "SELECT MAX(display_order) |
|
| 1247 | + $sql = "SELECT MAX(display_order) |
|
| 1248 | 1248 | FROM $link_table |
| 1249 | 1249 | WHERE |
| 1250 | 1250 | c_id = ".$this->destination_course_id." AND |
| 1251 | 1251 | category_id='" . intval($cat_id). "'"; |
| 1252 | - $result = Database::query($sql); |
|
| 1253 | - list($max_order) = Database::fetch_array($result); |
|
| 1252 | + $result = Database::query($sql); |
|
| 1253 | + list($max_order) = Database::fetch_array($result); |
|
| 1254 | 1254 | |
| 1255 | 1255 | $params = []; |
| 1256 | - if (!empty($session_id)) { |
|
| 1256 | + if (!empty($session_id)) { |
|
| 1257 | 1257 | $params['session_id'] = $session_id; |
| 1258 | - } |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | 1260 | $params['c_id'] = $this->destination_course_id; |
| 1261 | 1261 | $params['url'] = self::DBUTF8($link->url); |
@@ -1284,9 +1284,9 @@ discard block |
||
| 1284 | 1284 | } |
| 1285 | 1285 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
| 1286 | 1286 | } |
| 1287 | - } |
|
| 1288 | - } |
|
| 1289 | - } |
|
| 1287 | + } |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | 1290 | |
| 1291 | 1291 | /** |
| 1292 | 1292 | * Restore a link-category |
@@ -1331,21 +1331,21 @@ discard block |
||
| 1331 | 1331 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - /** |
|
| 1335 | - * Restore tool intro |
|
| 1336 | - */ |
|
| 1334 | + /** |
|
| 1335 | + * Restore tool intro |
|
| 1336 | + */ |
|
| 1337 | 1337 | public function restore_tool_intro($sessionId = 0) |
| 1338 | 1338 | { |
| 1339 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
| 1339 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
| 1340 | 1340 | $sessionId = intval($sessionId); |
| 1341 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
| 1342 | - $resources = $this->course->resources; |
|
| 1343 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
| 1344 | - $sql = "DELETE FROM $tool_intro_table |
|
| 1341 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
| 1342 | + $resources = $this->course->resources; |
|
| 1343 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
| 1344 | + $sql = "DELETE FROM $tool_intro_table |
|
| 1345 | 1345 | WHERE |
| 1346 | 1346 | c_id = ".$this->destination_course_id." AND |
| 1347 | 1347 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
| 1348 | - Database::query($sql); |
|
| 1348 | + Database::query($sql); |
|
| 1349 | 1349 | |
| 1350 | 1350 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1351 | 1351 | $tool_intro->intro_text, |
@@ -1370,21 +1370,21 @@ discard block |
||
| 1370 | 1370 | |
| 1371 | 1371 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
| 1372 | 1372 | } |
| 1373 | - } |
|
| 1374 | - } |
|
| 1375 | - } |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | + } |
|
| 1376 | 1376 | |
| 1377 | - /** |
|
| 1378 | - * Restore events |
|
| 1379 | - */ |
|
| 1377 | + /** |
|
| 1378 | + * Restore events |
|
| 1379 | + */ |
|
| 1380 | 1380 | public function restore_events($sessionId = 0) |
| 1381 | 1381 | { |
| 1382 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
| 1382 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
| 1383 | 1383 | $sessionId = intval($sessionId); |
| 1384 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
| 1385 | - $resources = $this->course->resources; |
|
| 1386 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
| 1387 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1384 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
| 1385 | + $resources = $this->course->resources; |
|
| 1386 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
| 1387 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1388 | 1388 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1389 | 1389 | $event->content, |
| 1390 | 1390 | $this->course->code, |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | 'end_date' => $event->end_date, |
| 1403 | 1403 | 'session_id' => $sessionId |
| 1404 | 1404 | ]; |
| 1405 | - $new_event_id = Database::insert($table, $params); |
|
| 1405 | + $new_event_id = Database::insert($table, $params); |
|
| 1406 | 1406 | |
| 1407 | 1407 | if ($new_event_id) { |
| 1408 | 1408 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1414,32 +1414,32 @@ discard block |
||
| 1414 | 1414 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | - // Copy event attachment |
|
| 1418 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
| 1419 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
| 1417 | + // Copy event attachment |
|
| 1418 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
| 1419 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
| 1420 | 1420 | |
| 1421 | - if (!empty($this->course->orig)) { |
|
| 1421 | + if (!empty($this->course->orig)) { |
|
| 1422 | 1422 | |
| 1423 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1424 | - $sql = 'SELECT path, comment, size, filename |
|
| 1423 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1424 | + $sql = 'SELECT path, comment, size, filename |
|
| 1425 | 1425 | FROM '.$table_attachment.' |
| 1426 | 1426 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
| 1427 | - $attachment_event = Database::query($sql); |
|
| 1428 | - $attachment_event = Database::fetch_object($attachment_event); |
|
| 1427 | + $attachment_event = Database::query($sql); |
|
| 1428 | + $attachment_event = Database::fetch_object($attachment_event); |
|
| 1429 | 1429 | |
| 1430 | - if (file_exists($origin_path.$attachment_event->path) && |
|
| 1430 | + if (file_exists($origin_path.$attachment_event->path) && |
|
| 1431 | 1431 | !is_dir($origin_path.$attachment_event->path) |
| 1432 | 1432 | ) { |
| 1433 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1433 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1434 | 1434 | $copy_result = copy( |
| 1435 | 1435 | $origin_path.$attachment_event->path, |
| 1436 | 1436 | $destination_path.$new_filename |
| 1437 | 1437 | ); |
| 1438 | - //$copy_result = true; |
|
| 1439 | - if ($copy_result) { |
|
| 1440 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1438 | + //$copy_result = true; |
|
| 1439 | + if ($copy_result) { |
|
| 1440 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1441 | 1441 | |
| 1442 | - $params = [ |
|
| 1442 | + $params = [ |
|
| 1443 | 1443 | 'c_id' => $this->destination_course_id, |
| 1444 | 1444 | 'path' => self::DBUTF8($new_filename), |
| 1445 | 1445 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1453,20 +1453,20 @@ discard block |
||
| 1453 | 1453 | Database::query($sql); |
| 1454 | 1454 | } |
| 1455 | 1455 | } |
| 1456 | - } |
|
| 1457 | - } else { |
|
| 1458 | - // get the info of the file |
|
| 1459 | - if (!empty($event->attachment_path) && |
|
| 1456 | + } |
|
| 1457 | + } else { |
|
| 1458 | + // get the info of the file |
|
| 1459 | + if (!empty($event->attachment_path) && |
|
| 1460 | 1460 | is_file($origin_path.$event->attachment_path) && |
| 1461 | 1461 | is_readable($origin_path.$event->attachment_path) |
| 1462 | 1462 | ) { |
| 1463 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1463 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1464 | 1464 | $copy_result = copy( |
| 1465 | 1465 | $origin_path.$event->attachment_path, |
| 1466 | 1466 | $destination_path.$new_filename |
| 1467 | 1467 | ); |
| 1468 | - if ($copy_result) { |
|
| 1469 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1468 | + if ($copy_result) { |
|
| 1469 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 1470 | 1470 | |
| 1471 | 1471 | $params = [ |
| 1472 | 1472 | 'c_id' => $this->destination_course_id, |
@@ -1482,29 +1482,29 @@ discard block |
||
| 1482 | 1482 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
| 1483 | 1483 | Database::query($sql); |
| 1484 | 1484 | } |
| 1485 | - } |
|
| 1486 | - } |
|
| 1487 | - } |
|
| 1488 | - } |
|
| 1489 | - } |
|
| 1490 | - } |
|
| 1491 | - |
|
| 1492 | - /** |
|
| 1493 | - * Restore course-description |
|
| 1494 | - */ |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1487 | + } |
|
| 1488 | + } |
|
| 1489 | + } |
|
| 1490 | + } |
|
| 1491 | + |
|
| 1492 | + /** |
|
| 1493 | + * Restore course-description |
|
| 1494 | + */ |
|
| 1495 | 1495 | public function restore_course_descriptions($session_id = 0) |
| 1496 | 1496 | { |
| 1497 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
| 1498 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
| 1499 | - $resources = $this->course->resources; |
|
| 1500 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
| 1497 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
| 1498 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
| 1499 | + $resources = $this->course->resources; |
|
| 1500 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
| 1501 | 1501 | $courseDescription = (array) $cd; |
| 1502 | 1502 | |
| 1503 | 1503 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
| 1504 | 1504 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
| 1505 | 1505 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
| 1506 | 1506 | |
| 1507 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1507 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1508 | 1508 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1509 | 1509 | $content, |
| 1510 | 1510 | $this->course->code, |
@@ -1533,22 +1533,22 @@ discard block |
||
| 1533 | 1533 | } |
| 1534 | 1534 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
| 1535 | 1535 | } |
| 1536 | - } |
|
| 1537 | - } |
|
| 1538 | - } |
|
| 1536 | + } |
|
| 1537 | + } |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - /** |
|
| 1541 | - * Restore announcements |
|
| 1542 | - */ |
|
| 1540 | + /** |
|
| 1541 | + * Restore announcements |
|
| 1542 | + */ |
|
| 1543 | 1543 | public function restore_announcements($sessionId = 0) |
| 1544 | 1544 | { |
| 1545 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
| 1545 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
| 1546 | 1546 | $sessionId = intval($sessionId); |
| 1547 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
| 1548 | - $resources = $this->course->resources; |
|
| 1549 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
| 1547 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
| 1548 | + $resources = $this->course->resources; |
|
| 1549 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
| 1550 | 1550 | |
| 1551 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1551 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1552 | 1552 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1553 | 1553 | $announcement->content, |
| 1554 | 1554 | $this->course->code, |
@@ -1567,7 +1567,7 @@ discard block |
||
| 1567 | 1567 | 'session_id' => $sessionId, |
| 1568 | 1568 | ]; |
| 1569 | 1569 | |
| 1570 | - $new_announcement_id = Database::insert($table, $params); |
|
| 1570 | + $new_announcement_id = Database::insert($table, $params); |
|
| 1571 | 1571 | |
| 1572 | 1572 | if ($new_announcement_id) { |
| 1573 | 1573 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1579,32 +1579,32 @@ discard block |
||
| 1579 | 1579 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
| 1583 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
| 1582 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
| 1583 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
| 1584 | 1584 | |
| 1585 | - // Copy announcement attachment file |
|
| 1586 | - if (!empty($this->course->orig)) { |
|
| 1585 | + // Copy announcement attachment file |
|
| 1586 | + if (!empty($this->course->orig)) { |
|
| 1587 | 1587 | |
| 1588 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1589 | - $sql = 'SELECT path, comment, size, filename |
|
| 1588 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1589 | + $sql = 'SELECT path, comment, size, filename |
|
| 1590 | 1590 | FROM '.$table_attachment.' |
| 1591 | 1591 | WHERE |
| 1592 | 1592 | c_id = '.$this->destination_course_id.' AND |
| 1593 | 1593 | announcement_id = '.$id; |
| 1594 | - $attachment_event = Database::query($sql); |
|
| 1595 | - $attachment_event = Database::fetch_object($attachment_event); |
|
| 1594 | + $attachment_event = Database::query($sql); |
|
| 1595 | + $attachment_event = Database::fetch_object($attachment_event); |
|
| 1596 | 1596 | |
| 1597 | - if (file_exists($origin_path.$attachment_event->path) && |
|
| 1597 | + if (file_exists($origin_path.$attachment_event->path) && |
|
| 1598 | 1598 | !is_dir($origin_path.$attachment_event->path) |
| 1599 | 1599 | ) { |
| 1600 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1600 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1601 | 1601 | $copy_result = copy( |
| 1602 | 1602 | $origin_path.$attachment_event->path, |
| 1603 | 1603 | $destination_path.$new_filename |
| 1604 | 1604 | ); |
| 1605 | 1605 | |
| 1606 | - if ($copy_result) { |
|
| 1607 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1606 | + if ($copy_result) { |
|
| 1607 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1608 | 1608 | |
| 1609 | 1609 | $params = [ |
| 1610 | 1610 | 'c_id' => $this->destination_course_id, |
@@ -1621,19 +1621,19 @@ discard block |
||
| 1621 | 1621 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
| 1622 | 1622 | Database::query($sql); |
| 1623 | 1623 | } |
| 1624 | - } |
|
| 1625 | - } |
|
| 1626 | - } else { |
|
| 1627 | - // get the info of the file |
|
| 1628 | - if (!empty($announcement->attachment_path) && |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | + } else { |
|
| 1627 | + // get the info of the file |
|
| 1628 | + if (!empty($announcement->attachment_path) && |
|
| 1629 | 1629 | is_file($origin_path.$announcement->attachment_path) && |
| 1630 | 1630 | is_readable($origin_path.$announcement->attachment_path) |
| 1631 | 1631 | ) { |
| 1632 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1633 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
| 1632 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
| 1633 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
| 1634 | 1634 | |
| 1635 | - if ($copy_result) { |
|
| 1636 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1635 | + if ($copy_result) { |
|
| 1636 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
| 1637 | 1637 | |
| 1638 | 1638 | $params = [ |
| 1639 | 1639 | 'c_id' => $this->destination_course_id, |
@@ -1650,12 +1650,12 @@ discard block |
||
| 1650 | 1650 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
| 1651 | 1651 | Database::query($sql); |
| 1652 | 1652 | } |
| 1653 | - } |
|
| 1654 | - } |
|
| 1655 | - } |
|
| 1656 | - } |
|
| 1657 | - } |
|
| 1658 | - } |
|
| 1653 | + } |
|
| 1654 | + } |
|
| 1655 | + } |
|
| 1656 | + } |
|
| 1657 | + } |
|
| 1658 | + } |
|
| 1659 | 1659 | |
| 1660 | 1660 | /** |
| 1661 | 1661 | * Restore Quiz |
@@ -1666,13 +1666,13 @@ discard block |
||
| 1666 | 1666 | $session_id = 0, |
| 1667 | 1667 | $respect_base_content = false |
| 1668 | 1668 | ) { |
| 1669 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
| 1670 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
| 1671 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
| 1672 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 1673 | - $resources = $this->course->resources; |
|
| 1669 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
| 1670 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
| 1671 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
| 1672 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
| 1673 | + $resources = $this->course->resources; |
|
| 1674 | 1674 | |
| 1675 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
| 1675 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
| 1676 | 1676 | if (isset($quiz->obj)) { |
| 1677 | 1677 | //For new imports |
| 1678 | 1678 | $quiz = $quiz->obj; |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | $quiz->obj = $quiz; |
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | - $doc = ''; |
|
| 1684 | + $doc = ''; |
|
| 1685 | 1685 | if (!empty($quiz->sound)) { |
| 1686 | 1686 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
| 1687 | 1687 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1689,14 +1689,14 @@ discard block |
||
| 1689 | 1689 | WHERE |
| 1690 | 1690 | c_id = " . $this->destination_course_id . " AND |
| 1691 | 1691 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
| 1692 | - $doc = Database::query($sql); |
|
| 1693 | - $doc = Database::fetch_object($doc); |
|
| 1694 | - $doc = str_replace('/audio/', '', $doc->path); |
|
| 1695 | - } |
|
| 1696 | - } |
|
| 1697 | - |
|
| 1698 | - if ($id != -1) { |
|
| 1699 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1692 | + $doc = Database::query($sql); |
|
| 1693 | + $doc = Database::fetch_object($doc); |
|
| 1694 | + $doc = str_replace('/audio/', '', $doc->path); |
|
| 1695 | + } |
|
| 1696 | + } |
|
| 1697 | + |
|
| 1698 | + if ($id != -1) { |
|
| 1699 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1700 | 1700 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1701 | 1701 | $quiz->description, |
| 1702 | 1702 | $this->course->code, |
@@ -1708,13 +1708,13 @@ discard block |
||
| 1708 | 1708 | $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time; |
| 1709 | 1709 | $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time; |
| 1710 | 1710 | |
| 1711 | - global $_custom; |
|
| 1712 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
| 1711 | + global $_custom; |
|
| 1712 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
| 1713 | 1713 | $_custom['exercises_clean_dates_when_restoring'] |
| 1714 | 1714 | ) { |
| 1715 | - $quiz->start_time = null; |
|
| 1716 | - $quiz->end_time = null; |
|
| 1717 | - } |
|
| 1715 | + $quiz->start_time = null; |
|
| 1716 | + $quiz->end_time = null; |
|
| 1717 | + } |
|
| 1718 | 1718 | |
| 1719 | 1719 | $params = array( |
| 1720 | 1720 | 'c_id' => $this->destination_course_id, |
@@ -1748,10 +1748,10 @@ discard block |
||
| 1748 | 1748 | } |
| 1749 | 1749 | $params['session_id'] = $my_session_id; |
| 1750 | 1750 | } else { |
| 1751 | - if (!empty($session_id)) { |
|
| 1752 | - $session_id = intval($session_id); |
|
| 1751 | + if (!empty($session_id)) { |
|
| 1752 | + $session_id = intval($session_id); |
|
| 1753 | 1753 | $params['session_id'] = $session_id; |
| 1754 | - } |
|
| 1754 | + } |
|
| 1755 | 1755 | } |
| 1756 | 1756 | $new_id = Database::insert($table_qui, $params); |
| 1757 | 1757 | |
@@ -1760,15 +1760,15 @@ discard block |
||
| 1760 | 1760 | Database::query($sql); |
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | - } else { |
|
| 1764 | - // $id = -1 identifies the fictionary test for collecting |
|
| 1765 | - // orphan questions. We do not store it in the database. |
|
| 1766 | - $new_id = -1; |
|
| 1767 | - } |
|
| 1763 | + } else { |
|
| 1764 | + // $id = -1 identifies the fictionary test for collecting |
|
| 1765 | + // orphan questions. We do not store it in the database. |
|
| 1766 | + $new_id = -1; |
|
| 1767 | + } |
|
| 1768 | 1768 | |
| 1769 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
| 1769 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
| 1770 | 1770 | |
| 1771 | - $order = 0; |
|
| 1771 | + $order = 0; |
|
| 1772 | 1772 | if (!empty($quiz->question_ids)) { |
| 1773 | 1773 | foreach ($quiz->question_ids as $index => $question_id) { |
| 1774 | 1774 | $qid = $this->restore_quiz_question($question_id); |
@@ -1781,31 +1781,31 @@ discard block |
||
| 1781 | 1781 | Database::query($sql); |
| 1782 | 1782 | } |
| 1783 | 1783 | } |
| 1784 | - } |
|
| 1785 | - } |
|
| 1786 | - } |
|
| 1784 | + } |
|
| 1785 | + } |
|
| 1786 | + } |
|
| 1787 | 1787 | |
| 1788 | - /** |
|
| 1789 | - * Restore quiz-questions |
|
| 1788 | + /** |
|
| 1789 | + * Restore quiz-questions |
|
| 1790 | 1790 | * @params int question id |
| 1791 | - */ |
|
| 1791 | + */ |
|
| 1792 | 1792 | public function restore_quiz_question($id) |
| 1793 | 1793 | { |
| 1794 | 1794 | $em = Database::getManager(); |
| 1795 | - $resources = $this->course->resources; |
|
| 1795 | + $resources = $this->course->resources; |
|
| 1796 | 1796 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
| 1797 | 1797 | |
| 1798 | - $new_id = 0; |
|
| 1798 | + $new_id = 0; |
|
| 1799 | 1799 | |
| 1800 | - if (is_object($question)) { |
|
| 1801 | - if ($question->is_restored()) { |
|
| 1802 | - return $question->destination_id; |
|
| 1803 | - } |
|
| 1804 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
| 1805 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
| 1800 | + if (is_object($question)) { |
|
| 1801 | + if ($question->is_restored()) { |
|
| 1802 | + return $question->destination_id; |
|
| 1803 | + } |
|
| 1804 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
| 1805 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
| 1806 | 1806 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
| 1807 | 1807 | |
| 1808 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1808 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1809 | 1809 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1810 | 1810 | $question->description, |
| 1811 | 1811 | $this->course->code, |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | 'extra' => self::DBUTF8($question->extra) |
| 1827 | 1827 | ]; |
| 1828 | 1828 | |
| 1829 | - $new_id = Database::insert($table_que, $params); |
|
| 1829 | + $new_id = Database::insert($table_que, $params); |
|
| 1830 | 1830 | |
| 1831 | 1831 | if ($new_id) { |
| 1832 | 1832 | $sql = "UPDATE $table_que SET id = iid WHERE iid = $new_id"; |
@@ -1861,7 +1861,7 @@ discard block |
||
| 1861 | 1861 | $allAnswers = []; |
| 1862 | 1862 | $onlyAnswers = []; |
| 1863 | 1863 | |
| 1864 | - if ($question->quiz_type == DRAGGABLE || $question->quiz_type == MATCHING ) { |
|
| 1864 | + if ($question->quiz_type == DRAGGABLE || $question->quiz_type == MATCHING ) { |
|
| 1865 | 1865 | $allAnswers = array_column($question->answers, 'answer', 'id'); |
| 1866 | 1866 | } |
| 1867 | 1867 | |
@@ -1901,11 +1901,11 @@ discard block |
||
| 1901 | 1901 | $correctAnswers[$answerId] = $answer['correct']; |
| 1902 | 1902 | $onlyAnswers[$answerId] = $answer['answer']; |
| 1903 | 1903 | } |
| 1904 | - } |
|
| 1905 | - } else { |
|
| 1904 | + } |
|
| 1905 | + } else { |
|
| 1906 | 1906 | |
| 1907 | - foreach ($question->answers as $index => $answer) { |
|
| 1908 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1907 | + foreach ($question->answers as $index => $answer) { |
|
| 1908 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 1909 | 1909 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 1910 | 1910 | $answer['answer'], |
| 1911 | 1911 | $this->course->code, |
@@ -1945,8 +1945,8 @@ discard block |
||
| 1945 | 1945 | |
| 1946 | 1946 | $correctAnswers[$answerId] = $answer['correct']; |
| 1947 | 1947 | $onlyAnswers[$answerId] = $answer['answer']; |
| 1948 | - } |
|
| 1949 | - } |
|
| 1948 | + } |
|
| 1949 | + } |
|
| 1950 | 1950 | |
| 1951 | 1951 | // Current course id |
| 1952 | 1952 | $course_id = api_get_course_int_id(); |
@@ -2067,13 +2067,13 @@ discard block |
||
| 2067 | 2067 | } |
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
| 2071 | - } |
|
| 2070 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
| 2071 | + } |
|
| 2072 | 2072 | |
| 2073 | - return $new_id; |
|
| 2074 | - } |
|
| 2073 | + return $new_id; |
|
| 2074 | + } |
|
| 2075 | 2075 | |
| 2076 | - /** |
|
| 2076 | + /** |
|
| 2077 | 2077 | * @todo : add session id when used for session |
| 2078 | 2078 | */ |
| 2079 | 2079 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2158,21 +2158,21 @@ discard block |
||
| 2158 | 2158 | $sessionId = intval($sessionId); |
| 2159 | 2159 | |
| 2160 | 2160 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
| 2161 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2162 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2163 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2164 | - $resources = $this->course->resources; |
|
| 2165 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
| 2161 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2162 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2163 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2164 | + $resources = $this->course->resources; |
|
| 2165 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
| 2166 | 2166 | |
| 2167 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
| 2167 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
| 2168 | 2168 | WHERE |
| 2169 | 2169 | c_id = '.$this->destination_course_id.' AND |
| 2170 | 2170 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
| 2171 | 2171 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
| 2172 | 2172 | |
| 2173 | - $result_check = Database::query($sql); |
|
| 2173 | + $result_check = Database::query($sql); |
|
| 2174 | 2174 | |
| 2175 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2175 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2176 | 2176 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2177 | 2177 | $survey->title, |
| 2178 | 2178 | $this->course->code, |
@@ -2226,20 +2226,20 @@ discard block |
||
| 2226 | 2226 | 'session_id' => $sessionId |
| 2227 | 2227 | ]; |
| 2228 | 2228 | |
| 2229 | - //An existing survey exists with the same code and the same language |
|
| 2230 | - if (Database::num_rows($result_check) == 1) { |
|
| 2231 | - switch ($this->file_option) { |
|
| 2232 | - case FILE_SKIP: |
|
| 2233 | - //Do nothing |
|
| 2234 | - break; |
|
| 2235 | - case FILE_RENAME: |
|
| 2236 | - $survey_code = $survey->code.'_'; |
|
| 2237 | - $i=1; |
|
| 2238 | - $temp_survey_code = $survey_code.$i; |
|
| 2239 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
| 2240 | - $temp_survey_code = $survey_code.++$i; |
|
| 2241 | - } |
|
| 2242 | - $survey_code = $temp_survey_code; |
|
| 2229 | + //An existing survey exists with the same code and the same language |
|
| 2230 | + if (Database::num_rows($result_check) == 1) { |
|
| 2231 | + switch ($this->file_option) { |
|
| 2232 | + case FILE_SKIP: |
|
| 2233 | + //Do nothing |
|
| 2234 | + break; |
|
| 2235 | + case FILE_RENAME: |
|
| 2236 | + $survey_code = $survey->code.'_'; |
|
| 2237 | + $i=1; |
|
| 2238 | + $temp_survey_code = $survey_code.$i; |
|
| 2239 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
| 2240 | + $temp_survey_code = $survey_code.++$i; |
|
| 2241 | + } |
|
| 2242 | + $survey_code = $temp_survey_code; |
|
| 2243 | 2243 | |
| 2244 | 2244 | $params['code'] = $survey_code; |
| 2245 | 2245 | $new_id = Database::insert($table_sur, $params); |
@@ -2258,25 +2258,25 @@ discard block |
||
| 2258 | 2258 | Database::query($sql); |
| 2259 | 2259 | } |
| 2260 | 2260 | } |
| 2261 | - break; |
|
| 2262 | - case FILE_OVERWRITE: |
|
| 2263 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
| 2264 | - // getting the information of the survey (used for when the survey is shared) |
|
| 2261 | + break; |
|
| 2262 | + case FILE_OVERWRITE: |
|
| 2263 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
| 2264 | + // getting the information of the survey (used for when the survey is shared) |
|
| 2265 | 2265 | |
| 2266 | - $sql = "SELECT * FROM $table_sur |
|
| 2266 | + $sql = "SELECT * FROM $table_sur |
|
| 2267 | 2267 | WHERE |
| 2268 | 2268 | c_id = ".$this->destination_course_id." AND |
| 2269 | 2269 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
| 2270 | - $result = Database::query($sql); |
|
| 2271 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2270 | + $result = Database::query($sql); |
|
| 2271 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2272 | 2272 | |
| 2273 | - // if the survey is shared => also delete the shared content |
|
| 2274 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
| 2273 | + // if the survey is shared => also delete the shared content |
|
| 2274 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
| 2275 | 2275 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
| 2276 | - } |
|
| 2277 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2276 | + } |
|
| 2277 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2278 | 2278 | |
| 2279 | - // Insert the new source survey |
|
| 2279 | + // Insert the new source survey |
|
| 2280 | 2280 | $new_id = Database::insert($table_sur, $params); |
| 2281 | 2281 | |
| 2282 | 2282 | if ($new_id) { |
@@ -2297,11 +2297,11 @@ discard block |
||
| 2297 | 2297 | Database::query($sql); |
| 2298 | 2298 | } |
| 2299 | 2299 | } |
| 2300 | - break; |
|
| 2301 | - default: |
|
| 2302 | - break; |
|
| 2303 | - } |
|
| 2304 | - } else { |
|
| 2300 | + break; |
|
| 2301 | + default: |
|
| 2302 | + break; |
|
| 2303 | + } |
|
| 2304 | + } else { |
|
| 2305 | 2305 | // No existing survey with the same language and the same code, we just copy the survey |
| 2306 | 2306 | $new_id = Database::insert($table_sur, $params); |
| 2307 | 2307 | |
@@ -2323,48 +2323,48 @@ discard block |
||
| 2323 | 2323 | Database::query($sql); |
| 2324 | 2324 | } |
| 2325 | 2325 | } |
| 2326 | - } |
|
| 2327 | - } |
|
| 2328 | - } |
|
| 2329 | - } |
|
| 2330 | - |
|
| 2331 | - /** |
|
| 2332 | - * Check availability of a survey code |
|
| 2333 | - * @param string $survey_code |
|
| 2334 | - */ |
|
| 2326 | + } |
|
| 2327 | + } |
|
| 2328 | + } |
|
| 2329 | + } |
|
| 2330 | + |
|
| 2331 | + /** |
|
| 2332 | + * Check availability of a survey code |
|
| 2333 | + * @param string $survey_code |
|
| 2334 | + */ |
|
| 2335 | 2335 | public function is_survey_code_available($survey_code) |
| 2336 | 2336 | { |
| 2337 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2338 | - $sql = "SELECT * FROM $table_sur |
|
| 2337 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
| 2338 | + $sql = "SELECT * FROM $table_sur |
|
| 2339 | 2339 | WHERE |
| 2340 | 2340 | c_id = ".$this->destination_course_id." AND |
| 2341 | 2341 | code = '".self::DBUTF8escapestring($survey_code)."'"; |
| 2342 | - $result = Database::query($sql); |
|
| 2342 | + $result = Database::query($sql); |
|
| 2343 | 2343 | if (Database::num_rows($result) > 0) { |
| 2344 | 2344 | return false; |
| 2345 | 2345 | } else { |
| 2346 | 2346 | return true; |
| 2347 | 2347 | } |
| 2348 | - } |
|
| 2348 | + } |
|
| 2349 | 2349 | |
| 2350 | - /** |
|
| 2351 | - * Restore survey-questions |
|
| 2352 | - * @param string $survey_id |
|
| 2353 | - */ |
|
| 2350 | + /** |
|
| 2351 | + * Restore survey-questions |
|
| 2352 | + * @param string $survey_id |
|
| 2353 | + */ |
|
| 2354 | 2354 | public function restore_survey_question($id, $survey_id) |
| 2355 | 2355 | { |
| 2356 | - $resources = $this->course->resources; |
|
| 2357 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
| 2356 | + $resources = $this->course->resources; |
|
| 2357 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
| 2358 | 2358 | $new_id = 0; |
| 2359 | 2359 | |
| 2360 | - if (is_object($question)) { |
|
| 2361 | - if ($question->is_restored()) { |
|
| 2362 | - return $question->destination_id; |
|
| 2363 | - } |
|
| 2364 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2365 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2360 | + if (is_object($question)) { |
|
| 2361 | + if ($question->is_restored()) { |
|
| 2362 | + return $question->destination_id; |
|
| 2363 | + } |
|
| 2364 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
| 2365 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
| 2366 | 2366 | |
| 2367 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2367 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2368 | 2368 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2369 | 2369 | $question->survey_question, |
| 2370 | 2370 | $this->course->code, |
@@ -2418,10 +2418,10 @@ discard block |
||
| 2418 | 2418 | } |
| 2419 | 2419 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
| 2420 | 2420 | } |
| 2421 | - } |
|
| 2421 | + } |
|
| 2422 | 2422 | |
| 2423 | - return $new_id; |
|
| 2424 | - } |
|
| 2423 | + return $new_id; |
|
| 2424 | + } |
|
| 2425 | 2425 | |
| 2426 | 2426 | /** |
| 2427 | 2427 | * Restoring learning paths |
@@ -2432,19 +2432,19 @@ discard block |
||
| 2432 | 2432 | { |
| 2433 | 2433 | $session_id = intval($session_id); |
| 2434 | 2434 | |
| 2435 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
| 2435 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
| 2436 | 2436 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
| 2437 | 2437 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
| 2438 | 2438 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
| 2439 | 2439 | |
| 2440 | - $resources = $this->course->resources; |
|
| 2440 | + $resources = $this->course->resources; |
|
| 2441 | 2441 | |
| 2442 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
| 2443 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
| 2442 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
| 2443 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
| 2444 | 2444 | |
| 2445 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
| 2446 | - $condition_session = ''; |
|
| 2447 | - if (!empty($session_id)) { |
|
| 2445 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
| 2446 | + $condition_session = ''; |
|
| 2447 | + if (!empty($session_id)) { |
|
| 2448 | 2448 | if ($respect_base_content) { |
| 2449 | 2449 | $my_session_id = $lp->session_id; |
| 2450 | 2450 | if (!empty($lp->session_id)) { |
@@ -2455,20 +2455,20 @@ discard block |
||
| 2455 | 2455 | $session_id = intval($session_id); |
| 2456 | 2456 | $condition_session = $session_id; |
| 2457 | 2457 | } |
| 2458 | - } |
|
| 2459 | - |
|
| 2460 | - // Adding the author's image |
|
| 2461 | - if (!empty($lp->preview_image)) { |
|
| 2462 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2463 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
| 2464 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
| 2465 | - if ($copy_result) { |
|
| 2466 | - $lp->preview_image = $new_filename; |
|
| 2467 | - } else { |
|
| 2468 | - $lp->preview_image =''; |
|
| 2469 | - } |
|
| 2470 | - } |
|
| 2471 | - } |
|
| 2458 | + } |
|
| 2459 | + |
|
| 2460 | + // Adding the author's image |
|
| 2461 | + if (!empty($lp->preview_image)) { |
|
| 2462 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2463 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
| 2464 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
| 2465 | + if ($copy_result) { |
|
| 2466 | + $lp->preview_image = $new_filename; |
|
| 2467 | + } else { |
|
| 2468 | + $lp->preview_image =''; |
|
| 2469 | + } |
|
| 2470 | + } |
|
| 2471 | + } |
|
| 2472 | 2472 | |
| 2473 | 2473 | if ($this->add_text_in_items) { |
| 2474 | 2474 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2526,7 +2526,7 @@ discard block |
||
| 2526 | 2526 | $params['session_id'] = $condition_session; |
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | - $new_lp_id = Database::insert($table_main, $params); |
|
| 2529 | + $new_lp_id = Database::insert($table_main, $params); |
|
| 2530 | 2530 | |
| 2531 | 2531 | if ($new_lp_id) { |
| 2532 | 2532 | |
@@ -2587,13 +2587,13 @@ discard block |
||
| 2587 | 2587 | $old_refs = array(); |
| 2588 | 2588 | $prerequisite_ids = array(); |
| 2589 | 2589 | |
| 2590 | - foreach ($lp->get_items() as $index => $item) { |
|
| 2591 | - // we set the ref code here and then we update in a for loop |
|
| 2592 | - $ref = $item['ref']; |
|
| 2590 | + foreach ($lp->get_items() as $index => $item) { |
|
| 2591 | + // we set the ref code here and then we update in a for loop |
|
| 2592 | + $ref = $item['ref']; |
|
| 2593 | 2593 | |
| 2594 | - // Dealing with path the same way as ref as some data has |
|
| 2594 | + // Dealing with path the same way as ref as some data has |
|
| 2595 | 2595 | // been put into path when it's a local resource |
| 2596 | - // Only fix the path for no scos |
|
| 2596 | + // Only fix the path for no scos |
|
| 2597 | 2597 | if ($item['item_type'] == 'sco') { |
| 2598 | 2598 | $path = $item['path']; |
| 2599 | 2599 | } else { |
@@ -2624,128 +2624,128 @@ discard block |
||
| 2624 | 2624 | 'launch_data' => self::DBUTF8($item['launch_data']), |
| 2625 | 2625 | ]; |
| 2626 | 2626 | |
| 2627 | - $new_item_id = Database::insert($table_item, $params); |
|
| 2627 | + $new_item_id = Database::insert($table_item, $params); |
|
| 2628 | 2628 | |
| 2629 | 2629 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
| 2630 | 2630 | Database::query($sql); |
| 2631 | 2631 | |
| 2632 | - //save a link between old and new item IDs |
|
| 2633 | - $new_item_ids[$item['id']] = $new_item_id; |
|
| 2634 | - //save a reference of items that need a parent_item_id refresh |
|
| 2635 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
| 2636 | - //save a reference of items that need a previous_item_id refresh |
|
| 2637 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
| 2638 | - //save a reference of items that need a next_item_id refresh |
|
| 2639 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
| 2640 | - |
|
| 2641 | - if (!empty($item['prerequisite'])) { |
|
| 2642 | - if ($lp->lp_type =='2') { |
|
| 2643 | - // if is an sco |
|
| 2644 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2645 | - } else { |
|
| 2646 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2647 | - } |
|
| 2648 | - } |
|
| 2649 | - |
|
| 2650 | - if (!empty($ref)) { |
|
| 2651 | - if ($lp->lp_type =='2') { |
|
| 2652 | - // if is an sco |
|
| 2653 | - $old_refs[$new_item_id]= $ref; |
|
| 2654 | - } elseif (isset($new_item_ids[$ref])) { |
|
| 2632 | + //save a link between old and new item IDs |
|
| 2633 | + $new_item_ids[$item['id']] = $new_item_id; |
|
| 2634 | + //save a reference of items that need a parent_item_id refresh |
|
| 2635 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
| 2636 | + //save a reference of items that need a previous_item_id refresh |
|
| 2637 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
| 2638 | + //save a reference of items that need a next_item_id refresh |
|
| 2639 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
| 2640 | + |
|
| 2641 | + if (!empty($item['prerequisite'])) { |
|
| 2642 | + if ($lp->lp_type =='2') { |
|
| 2643 | + // if is an sco |
|
| 2644 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2645 | + } else { |
|
| 2646 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2647 | + } |
|
| 2648 | + } |
|
| 2649 | + |
|
| 2650 | + if (!empty($ref)) { |
|
| 2651 | + if ($lp->lp_type =='2') { |
|
| 2652 | + // if is an sco |
|
| 2653 | + $old_refs[$new_item_id]= $ref; |
|
| 2654 | + } elseif (isset($new_item_ids[$ref])) { |
|
| 2655 | 2655 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
| 2656 | 2656 | } |
| 2657 | - } |
|
| 2657 | + } |
|
| 2658 | 2658 | |
| 2659 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
| 2660 | - } |
|
| 2659 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
| 2660 | + } |
|
| 2661 | 2661 | |
| 2662 | - // Updating prerequisites |
|
| 2663 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
| 2664 | - if ($my_old_prerequisite != ''){ |
|
| 2665 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
| 2662 | + // Updating prerequisites |
|
| 2663 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
| 2664 | + if ($my_old_prerequisite != ''){ |
|
| 2665 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
| 2666 | 2666 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2667 | - Database::query($sql); |
|
| 2668 | - } |
|
| 2669 | - } |
|
| 2670 | - |
|
| 2671 | - // Updating refs |
|
| 2672 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
| 2673 | - if ($my_old_ref != '') { |
|
| 2674 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
| 2667 | + Database::query($sql); |
|
| 2668 | + } |
|
| 2669 | + } |
|
| 2670 | + |
|
| 2671 | + // Updating refs |
|
| 2672 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
| 2673 | + if ($my_old_ref != '') { |
|
| 2674 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
| 2675 | 2675 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2676 | - Database::query($sql); |
|
| 2677 | - } |
|
| 2678 | - } |
|
| 2679 | - |
|
| 2680 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
| 2681 | - $parent_new_id = 0; |
|
| 2682 | - if($parent_item_old_id != 0){ |
|
| 2683 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
| 2684 | - } |
|
| 2685 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
| 2676 | + Database::query($sql); |
|
| 2677 | + } |
|
| 2678 | + } |
|
| 2679 | + |
|
| 2680 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
| 2681 | + $parent_new_id = 0; |
|
| 2682 | + if($parent_item_old_id != 0){ |
|
| 2683 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
| 2684 | + } |
|
| 2685 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
| 2686 | 2686 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2687 | - Database::query($sql); |
|
| 2688 | - } |
|
| 2689 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
| 2690 | - $previous_new_id = 0; |
|
| 2691 | - if ($previous_item_old_id != 0){ |
|
| 2692 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
| 2693 | - } |
|
| 2694 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
| 2687 | + Database::query($sql); |
|
| 2688 | + } |
|
| 2689 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
| 2690 | + $previous_new_id = 0; |
|
| 2691 | + if ($previous_item_old_id != 0){ |
|
| 2692 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
| 2693 | + } |
|
| 2694 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
| 2695 | 2695 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2696 | - Database::query($sql); |
|
| 2697 | - } |
|
| 2698 | - |
|
| 2699 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
| 2700 | - $next_new_id = 0; |
|
| 2701 | - if ($next_item_old_id != 0){ |
|
| 2702 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
| 2703 | - } |
|
| 2704 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
| 2696 | + Database::query($sql); |
|
| 2697 | + } |
|
| 2698 | + |
|
| 2699 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
| 2700 | + $next_new_id = 0; |
|
| 2701 | + if ($next_item_old_id != 0){ |
|
| 2702 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
| 2703 | + } |
|
| 2704 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
| 2705 | 2705 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2706 | - Database::query($sql); |
|
| 2707 | - } |
|
| 2708 | - |
|
| 2709 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
| 2710 | - $prerequisite_new_id = 0; |
|
| 2711 | - if ($prerequisite_old_id != 0){ |
|
| 2712 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
| 2713 | - } |
|
| 2714 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
| 2706 | + Database::query($sql); |
|
| 2707 | + } |
|
| 2708 | + |
|
| 2709 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
| 2710 | + $prerequisite_new_id = 0; |
|
| 2711 | + if ($prerequisite_old_id != 0){ |
|
| 2712 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
| 2713 | + } |
|
| 2714 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
| 2715 | 2715 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
| 2716 | - Database::query($sql); |
|
| 2717 | - } |
|
| 2718 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
| 2719 | - } |
|
| 2720 | - } |
|
| 2721 | - } |
|
| 2722 | - |
|
| 2723 | - /** |
|
| 2724 | - * Restore works |
|
| 2716 | + Database::query($sql); |
|
| 2717 | + } |
|
| 2718 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
| 2719 | + } |
|
| 2720 | + } |
|
| 2721 | + } |
|
| 2722 | + |
|
| 2723 | + /** |
|
| 2724 | + * Restore works |
|
| 2725 | 2725 | * @deprecated use restore_works |
| 2726 | 2726 | * |
| 2727 | - */ |
|
| 2728 | - public function restore_student_publication($sessionId = 0) |
|
| 2727 | + */ |
|
| 2728 | + public function restore_student_publication($sessionId = 0) |
|
| 2729 | 2729 | { |
| 2730 | 2730 | $sessionId = intval($sessionId); |
| 2731 | 2731 | $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
| 2732 | 2732 | $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); |
| 2733 | 2733 | $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY); |
| 2734 | 2734 | |
| 2735 | - // Query in student publication |
|
| 2736 | - $sql = 'SELECT * FROM '.$work_table.' |
|
| 2735 | + // Query in student publication |
|
| 2736 | + $sql = 'SELECT * FROM '.$work_table.' |
|
| 2737 | 2737 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
| 2738 | 2738 | |
| 2739 | - $result = Database::query($sql); |
|
| 2740 | - $folders = Database::store_result($result, 'ASSOC'); |
|
| 2739 | + $result = Database::query($sql); |
|
| 2740 | + $folders = Database::store_result($result, 'ASSOC'); |
|
| 2741 | 2741 | |
| 2742 | - foreach ($folders as $folder) { |
|
| 2743 | - $old_id = $folder['id']; |
|
| 2742 | + foreach ($folders as $folder) { |
|
| 2743 | + $old_id = $folder['id']; |
|
| 2744 | 2744 | unset($folder['id']); |
| 2745 | - $folder['c_id'] = $this->destination_course_id; |
|
| 2745 | + $folder['c_id'] = $this->destination_course_id; |
|
| 2746 | 2746 | $folder['parent_id'] = 0; |
| 2747 | 2747 | $folder['session_id'] = $sessionId ? $sessionId : null; |
| 2748 | - $new_id = Database::insert($work_table, $folder); |
|
| 2748 | + $new_id = Database::insert($work_table, $folder); |
|
| 2749 | 2749 | |
| 2750 | 2750 | if ($new_id) { |
| 2751 | 2751 | // query in item property |
@@ -2804,23 +2804,23 @@ discard block |
||
| 2804 | 2804 | } |
| 2805 | 2805 | } |
| 2806 | 2806 | } |
| 2807 | - } |
|
| 2807 | + } |
|
| 2808 | 2808 | |
| 2809 | 2809 | $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/'; |
| 2810 | 2810 | $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/'; |
| 2811 | 2811 | self::allow_create_all_directory($origin, $destination, false); |
| 2812 | - } |
|
| 2812 | + } |
|
| 2813 | 2813 | |
| 2814 | 2814 | /** |
| 2815 | - * copy all directory and sub directory |
|
| 2816 | - * @param string The path origin |
|
| 2817 | - * @param string The path destination |
|
| 2818 | - * @param boolean Option Overwrite |
|
| 2819 | - * @param string $source |
|
| 2820 | - * @param string $dest |
|
| 2821 | - * @return void() |
|
| 2822 | - * @deprecated |
|
| 2823 | - */ |
|
| 2815 | + * copy all directory and sub directory |
|
| 2816 | + * @param string The path origin |
|
| 2817 | + * @param string The path destination |
|
| 2818 | + * @param boolean Option Overwrite |
|
| 2819 | + * @param string $source |
|
| 2820 | + * @param string $dest |
|
| 2821 | + * @return void() |
|
| 2822 | + * @deprecated |
|
| 2823 | + */ |
|
| 2824 | 2824 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
| 2825 | 2825 | { |
| 2826 | 2826 | if (!is_dir($dest)) { |
@@ -2831,7 +2831,7 @@ discard block |
||
| 2831 | 2831 | if ($file != '.' && $file != '..') { |
| 2832 | 2832 | $path = $source . '/' . $file; |
| 2833 | 2833 | if (is_file($path)) { |
| 2834 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
| 2834 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
| 2835 | 2835 | if (!@copy($path, $dest . '/' . $file)) { |
| 2836 | 2836 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
| 2837 | 2837 | }*/ |
@@ -2846,12 +2846,12 @@ discard block |
||
| 2846 | 2846 | } |
| 2847 | 2847 | } |
| 2848 | 2848 | |
| 2849 | - /** |
|
| 2850 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
| 2851 | - * @param string Tool name |
|
| 2852 | - * @param integer Old ID |
|
| 2853 | - * @return integer New ID |
|
| 2854 | - */ |
|
| 2849 | + /** |
|
| 2850 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
| 2851 | + * @param string Tool name |
|
| 2852 | + * @param integer Old ID |
|
| 2853 | + * @return integer New ID |
|
| 2854 | + */ |
|
| 2855 | 2855 | public function get_new_id($tool, $ref) |
| 2856 | 2856 | { |
| 2857 | 2857 | // Check if the value exist in the current array. |
@@ -2873,25 +2873,25 @@ discard block |
||
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | return ''; |
| 2876 | - } |
|
| 2876 | + } |
|
| 2877 | 2877 | |
| 2878 | - /** |
|
| 2879 | - * Restore glossary |
|
| 2880 | - */ |
|
| 2878 | + /** |
|
| 2879 | + * Restore glossary |
|
| 2880 | + */ |
|
| 2881 | 2881 | public function restore_glossary($session_id = 0) |
| 2882 | 2882 | { |
| 2883 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
| 2884 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
| 2885 | - $resources = $this->course->resources; |
|
| 2886 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
| 2883 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
| 2884 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
| 2885 | + $resources = $this->course->resources; |
|
| 2886 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
| 2887 | 2887 | |
| 2888 | 2888 | $params = []; |
| 2889 | - if (!empty($session_id)) { |
|
| 2890 | - $session_id = intval($session_id); |
|
| 2889 | + if (!empty($session_id)) { |
|
| 2890 | + $session_id = intval($session_id); |
|
| 2891 | 2891 | $params['session_id'] = $session_id; |
| 2892 | - } |
|
| 2892 | + } |
|
| 2893 | 2893 | |
| 2894 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2894 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2895 | 2895 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2896 | 2896 | $glossary->description, |
| 2897 | 2897 | $this->course->code, |
@@ -2925,27 +2925,27 @@ discard block |
||
| 2925 | 2925 | |
| 2926 | 2926 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
| 2927 | 2927 | } |
| 2928 | - } |
|
| 2929 | - } |
|
| 2930 | - } |
|
| 2928 | + } |
|
| 2929 | + } |
|
| 2930 | + } |
|
| 2931 | 2931 | |
| 2932 | 2932 | /** |
| 2933 | 2933 | * @param int $session_id |
| 2934 | 2934 | */ |
| 2935 | 2935 | public function restore_wiki($session_id = 0) |
| 2936 | 2936 | { |
| 2937 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
| 2938 | - // wiki table of the target course |
|
| 2939 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
| 2940 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
| 2937 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
| 2938 | + // wiki table of the target course |
|
| 2939 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
| 2940 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
| 2941 | 2941 | |
| 2942 | - // storing all the resources that have to be copied in an array |
|
| 2943 | - $resources = $this->course->resources; |
|
| 2942 | + // storing all the resources that have to be copied in an array |
|
| 2943 | + $resources = $this->course->resources; |
|
| 2944 | 2944 | |
| 2945 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
| 2946 | - // the sql statement to insert the groups from the old course to the new course |
|
| 2945 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
| 2946 | + // the sql statement to insert the groups from the old course to the new course |
|
| 2947 | 2947 | |
| 2948 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2948 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 2949 | 2949 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 2950 | 2950 | $wiki->content, |
| 2951 | 2951 | $this->course->code, |
@@ -2980,7 +2980,7 @@ discard block |
||
| 2980 | 2980 | 'user_ip' => '' |
| 2981 | 2981 | ]; |
| 2982 | 2982 | |
| 2983 | - $new_id = Database::insert($table_wiki, $params); |
|
| 2983 | + $new_id = Database::insert($table_wiki, $params); |
|
| 2984 | 2984 | |
| 2985 | 2985 | if ($new_id) { |
| 2986 | 2986 | $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid |
@@ -3010,9 +3010,9 @@ discard block |
||
| 3010 | 3010 | |
| 3011 | 3011 | Database::insert($table_wiki_conf, $params); |
| 3012 | 3012 | } |
| 3013 | - } |
|
| 3014 | - } |
|
| 3015 | - } |
|
| 3013 | + } |
|
| 3014 | + } |
|
| 3015 | + } |
|
| 3016 | 3016 | |
| 3017 | 3017 | /** |
| 3018 | 3018 | * Restore Thematics |
@@ -3020,15 +3020,15 @@ discard block |
||
| 3020 | 3020 | */ |
| 3021 | 3021 | public function restore_thematic($session_id = 0) |
| 3022 | 3022 | { |
| 3023 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
| 3023 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
| 3024 | 3024 | $table_thematic = Database::get_course_table(TABLE_THEMATIC); |
| 3025 | 3025 | $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); |
| 3026 | 3026 | $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); |
| 3027 | 3027 | |
| 3028 | - $resources = $this->course->resources; |
|
| 3029 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
| 3028 | + $resources = $this->course->resources; |
|
| 3029 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
| 3030 | 3030 | |
| 3031 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3031 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3032 | 3032 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 3033 | 3033 | $thematic->params['content'], |
| 3034 | 3034 | $this->course->code, |
@@ -3036,13 +3036,13 @@ discard block |
||
| 3036 | 3036 | $this->course->backup_path, |
| 3037 | 3037 | $this->course->info['path'] |
| 3038 | 3038 | ); |
| 3039 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
| 3040 | - unset($thematic->params['id']); |
|
| 3039 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
| 3040 | + unset($thematic->params['id']); |
|
| 3041 | 3041 | unset($thematic->params['iid']); |
| 3042 | 3042 | |
| 3043 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
| 3043 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
| 3044 | 3044 | |
| 3045 | - if ($last_id) { |
|
| 3045 | + if ($last_id) { |
|
| 3046 | 3046 | |
| 3047 | 3047 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
| 3048 | 3048 | Database::query($sql); |
@@ -3055,12 +3055,12 @@ discard block |
||
| 3055 | 3055 | api_get_user_id() |
| 3056 | 3056 | ); |
| 3057 | 3057 | |
| 3058 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
| 3059 | - unset($thematic_advance['id']); |
|
| 3058 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
| 3059 | + unset($thematic_advance['id']); |
|
| 3060 | 3060 | unset($thematic_advance['iid']); |
| 3061 | - $thematic_advance['attendance_id'] = 0; |
|
| 3062 | - $thematic_advance['thematic_id'] = $last_id; |
|
| 3063 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3061 | + $thematic_advance['attendance_id'] = 0; |
|
| 3062 | + $thematic_advance['thematic_id'] = $last_id; |
|
| 3063 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3064 | 3064 | |
| 3065 | 3065 | $my_id = Database::insert( |
| 3066 | 3066 | $table_thematic_advance, |
@@ -3068,7 +3068,7 @@ discard block |
||
| 3068 | 3068 | false |
| 3069 | 3069 | ); |
| 3070 | 3070 | |
| 3071 | - if ($my_id) { |
|
| 3071 | + if ($my_id) { |
|
| 3072 | 3072 | |
| 3073 | 3073 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
| 3074 | 3074 | Database::query($sql); |
@@ -3080,17 +3080,17 @@ discard block |
||
| 3080 | 3080 | 'ThematicAdvanceAdded', |
| 3081 | 3081 | api_get_user_id() |
| 3082 | 3082 | ); |
| 3083 | - } |
|
| 3084 | - } |
|
| 3083 | + } |
|
| 3084 | + } |
|
| 3085 | 3085 | |
| 3086 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3087 | - unset($thematic_plan['id']); |
|
| 3086 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3087 | + unset($thematic_plan['id']); |
|
| 3088 | 3088 | unset($thematic_plan['iid']); |
| 3089 | - $thematic_plan['thematic_id'] = $last_id; |
|
| 3090 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
| 3091 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
| 3089 | + $thematic_plan['thematic_id'] = $last_id; |
|
| 3090 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
| 3091 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
| 3092 | 3092 | |
| 3093 | - if ($my_id) { |
|
| 3093 | + if ($my_id) { |
|
| 3094 | 3094 | |
| 3095 | 3095 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
| 3096 | 3096 | Database::query($sql); |
@@ -3102,12 +3102,12 @@ discard block |
||
| 3102 | 3102 | 'ThematicPlanAdded', |
| 3103 | 3103 | api_get_user_id() |
| 3104 | 3104 | ); |
| 3105 | - } |
|
| 3106 | - } |
|
| 3107 | - } |
|
| 3108 | - } |
|
| 3109 | - } |
|
| 3110 | - } |
|
| 3105 | + } |
|
| 3106 | + } |
|
| 3107 | + } |
|
| 3108 | + } |
|
| 3109 | + } |
|
| 3110 | + } |
|
| 3111 | 3111 | |
| 3112 | 3112 | /** |
| 3113 | 3113 | * Restore Attendance |
@@ -3115,14 +3115,14 @@ discard block |
||
| 3115 | 3115 | */ |
| 3116 | 3116 | public function restore_attendance($session_id = 0) |
| 3117 | 3117 | { |
| 3118 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
| 3119 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
| 3120 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
| 3118 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
| 3119 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
| 3120 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
| 3121 | 3121 | |
| 3122 | - $resources = $this->course->resources; |
|
| 3123 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
| 3122 | + $resources = $this->course->resources; |
|
| 3123 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
| 3124 | 3124 | |
| 3125 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3125 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
| 3126 | 3126 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
| 3127 | 3127 | $obj->params['description'], |
| 3128 | 3128 | $this->course->code, |
@@ -3134,11 +3134,11 @@ discard block |
||
| 3134 | 3134 | unset($obj->params['id']); |
| 3135 | 3135 | unset($obj->params['iid']); |
| 3136 | 3136 | |
| 3137 | - $obj->params['c_id'] = $this->destination_course_id; |
|
| 3137 | + $obj->params['c_id'] = $this->destination_course_id; |
|
| 3138 | 3138 | |
| 3139 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
| 3139 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
| 3140 | 3140 | |
| 3141 | - if (is_numeric($last_id)) { |
|
| 3141 | + if (is_numeric($last_id)) { |
|
| 3142 | 3142 | |
| 3143 | 3143 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
| 3144 | 3144 | Database::query($sql); |
@@ -3152,11 +3152,11 @@ discard block |
||
| 3152 | 3152 | ); |
| 3153 | 3153 | |
| 3154 | 3154 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
| 3155 | - unset($attendance_calendar['id']); |
|
| 3155 | + unset($attendance_calendar['id']); |
|
| 3156 | 3156 | unset($attendance_calendar['iid']); |
| 3157 | 3157 | |
| 3158 | - $attendance_calendar['attendance_id'] = $last_id; |
|
| 3159 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
| 3158 | + $attendance_calendar['attendance_id'] = $last_id; |
|
| 3159 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
| 3160 | 3160 | $attendanceCalendarId = Database::insert( |
| 3161 | 3161 | $table_attendance_calendar, |
| 3162 | 3162 | $attendance_calendar |
@@ -3164,11 +3164,11 @@ discard block |
||
| 3164 | 3164 | |
| 3165 | 3165 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
| 3166 | 3166 | Database::query($sql); |
| 3167 | - } |
|
| 3168 | - } |
|
| 3169 | - } |
|
| 3170 | - } |
|
| 3171 | - } |
|
| 3167 | + } |
|
| 3168 | + } |
|
| 3169 | + } |
|
| 3170 | + } |
|
| 3171 | + } |
|
| 3172 | 3172 | |
| 3173 | 3173 | /** |
| 3174 | 3174 | * Restore Works |
@@ -3309,11 +3309,11 @@ discard block |
||
| 3309 | 3309 | */ |
| 3310 | 3310 | public function DBUTF8($str) |
| 3311 | 3311 | { |
| 3312 | - if (UTF8_CONVERT) { |
|
| 3312 | + if (UTF8_CONVERT) { |
|
| 3313 | 3313 | $str = utf8_encode($str); |
| 3314 | 3314 | } |
| 3315 | - return $str; |
|
| 3316 | - } |
|
| 3315 | + return $str; |
|
| 3316 | + } |
|
| 3317 | 3317 | |
| 3318 | 3318 | /** |
| 3319 | 3319 | * @param string $str |
@@ -3324,8 +3324,8 @@ discard block |
||
| 3324 | 3324 | if (UTF8_CONVERT) { |
| 3325 | 3325 | $str = utf8_encode($str); |
| 3326 | 3326 | } |
| 3327 | - return Database::escape_string($str); |
|
| 3328 | - } |
|
| 3327 | + return Database::escape_string($str); |
|
| 3328 | + } |
|
| 3329 | 3329 | |
| 3330 | 3330 | /** |
| 3331 | 3331 | * @param array $array |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $params['lastedit_date'] = self::DBUTF8($property['lastedit_date']); |
| 218 | 218 | $params['ref'] = $resource->destination_id; |
| 219 | 219 | $params['lastedit_type'] = self::DBUTF8($property['lastedit_type']); |
| 220 | - $params['lastedit_user_id'] = $this->checkUserId($property['lastedit_user_id']); |
|
| 220 | + $params['lastedit_user_id'] = $this->checkUserId($property['lastedit_user_id']); |
|
| 221 | 221 | $params['visibility'] = self::DBUTF8($property['visibility']); |
| 222 | 222 | $params['start_visible'] = self::DBUTF8($property['start_visible']); |
| 223 | 223 | $params['end_visible'] = self::DBUTF8($property['end_visible']); |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 579 | 579 | $file_exists = file_exists($path.$new_file_name); |
| 580 | 580 | while ($file_exists) { |
| 581 | - $i ++; |
|
| 581 | + $i++; |
|
| 582 | 582 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 583 | 583 | $file_exists = file_exists($path.$new_file_name); |
| 584 | 584 | } |
@@ -622,9 +622,9 @@ discard block |
||
| 622 | 622 | $new_base_path = $_SESSION['new_base_path']; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 626 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 627 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 625 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
| 626 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
| 627 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
| 628 | 628 | $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
| 629 | 629 | |
| 630 | 630 | copy_folder_course_session( |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | // Replace old course code with the new destination code see BT#1985 |
| 644 | 644 | if (file_exists($dest_document_path)) { |
| 645 | 645 | $file_info = pathinfo($dest_document_path); |
| 646 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 646 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 647 | 647 | $content = file_get_contents($dest_document_path); |
| 648 | 648 | if (UTF8_CONVERT) { |
| 649 | 649 | $content = utf8_encode($content); |
@@ -705,8 +705,8 @@ discard block |
||
| 705 | 705 | //Replace old course code with the new destination code see BT#1985 |
| 706 | 706 | if (file_exists($path.$new_file_name)) { |
| 707 | 707 | $file_info = pathinfo($path.$new_file_name); |
| 708 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 709 | - $content = file_get_contents($path.$new_file_name); |
|
| 708 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 709 | + $content = file_get_contents($path.$new_file_name); |
|
| 710 | 710 | if (UTF8_CONVERT) { |
| 711 | 711 | $content = utf8_encode($content); |
| 712 | 712 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | // Replace old course code with the new destination code see BT#1985 |
| 771 | 771 | if (file_exists($path.$new_file_name)) { |
| 772 | 772 | $file_info = pathinfo($path.$new_file_name); |
| 773 | - if (in_array($file_info['extension'], array('html','htm'))) { |
|
| 773 | + if (in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 774 | 774 | $content = file_get_contents($path.$new_file_name); |
| 775 | 775 | if (UTF8_CONVERT) { |
| 776 | 776 | $content = utf8_encode($content); |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | // Replace old course code with the new destination code see BT#1985 |
| 846 | 846 | if (file_exists($path.$document->path)) { |
| 847 | 847 | $file_info = pathinfo($path.$document->path); |
| 848 | - if (isset($file_info['extension']) && in_array($file_info['extension'], array('html','htm'))) { |
|
| 848 | + if (isset($file_info['extension']) && in_array($file_info['extension'], array('html', 'htm'))) { |
|
| 849 | 849 | $content = file_get_contents($path.$document->path); |
| 850 | 850 | if (UTF8_CONVERT) { |
| 851 | 851 | $content = utf8_encode($content); |
@@ -945,8 +945,8 @@ discard block |
||
| 945 | 945 | case FILE_OVERWRITE: |
| 946 | 946 | rmdirr($path.$document->path); |
| 947 | 947 | copyDirTo( |
| 948 | - $this->course->backup_path . '/' . $document->path, |
|
| 949 | - $path . dirname($document->path), |
|
| 948 | + $this->course->backup_path.'/'.$document->path, |
|
| 949 | + $path.dirname($document->path), |
|
| 950 | 950 | false |
| 951 | 951 | ); |
| 952 | 952 | break; |
@@ -968,23 +968,23 @@ discard block |
||
| 968 | 968 | $file_exists = file_exists($path.$new_file_name); |
| 969 | 969 | |
| 970 | 970 | while ($file_exists) { |
| 971 | - $i ++; |
|
| 971 | + $i++; |
|
| 972 | 972 | $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
| 973 | 973 | $file_exists = file_exists($path.$new_file_name); |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | rename( |
| 977 | - $this->course->backup_path . '/' . $document->path, |
|
| 978 | - $this->course->backup_path . '/' . $new_file_name |
|
| 977 | + $this->course->backup_path.'/'.$document->path, |
|
| 978 | + $this->course->backup_path.'/'.$new_file_name |
|
| 979 | 979 | ); |
| 980 | 980 | copyDirTo( |
| 981 | - $this->course->backup_path . '/' . $new_file_name, |
|
| 982 | - $path . dirname($new_file_name), |
|
| 981 | + $this->course->backup_path.'/'.$new_file_name, |
|
| 982 | + $path.dirname($new_file_name), |
|
| 983 | 983 | false |
| 984 | 984 | ); |
| 985 | 985 | rename( |
| 986 | - $this->course->backup_path . '/' . $new_file_name, |
|
| 987 | - $this->course->backup_path . '/' . $document->path |
|
| 986 | + $this->course->backup_path.'/'.$new_file_name, |
|
| 987 | + $this->course->backup_path.'/'.$document->path |
|
| 988 | 988 | ); |
| 989 | 989 | |
| 990 | 990 | break; |
@@ -992,8 +992,8 @@ discard block |
||
| 992 | 992 | } else { |
| 993 | 993 | // end if file exists |
| 994 | 994 | copyDirTo( |
| 995 | - $this->course->backup_path . '/' . $document->path, |
|
| 996 | - $path . dirname($document->path), |
|
| 995 | + $this->course->backup_path.'/'.$document->path, |
|
| 996 | + $path.dirname($document->path), |
|
| 997 | 997 | false |
| 998 | 998 | ); |
| 999 | 999 | } |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $table_forum = Database::get_course_table(TABLE_FORUM); |
| 1014 | 1014 | $resources = $this->course->resources; |
| 1015 | 1015 | foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
| 1016 | - $params = (array)$forum->obj; |
|
| 1016 | + $params = (array) $forum->obj; |
|
| 1017 | 1017 | $cat_id = ''; |
| 1018 | 1018 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
| 1019 | 1019 | isset($this->course->resources[RESOURCE_FORUMCATEGORY][$params['forum_category']])) { |
@@ -1066,13 +1066,13 @@ discard block |
||
| 1066 | 1066 | foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
| 1067 | 1067 | if ($topic->obj->forum_id == $id) { |
| 1068 | 1068 | $this->restore_topic($topic_id, $new_id, $sessionId); |
| 1069 | - $forum_topics ++; |
|
| 1069 | + $forum_topics++; |
|
| 1070 | 1070 | } |
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| 1073 | 1073 | if ($forum_topics > 0) { |
| 1074 | 1074 | $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
| 1075 | - WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
|
| 1075 | + WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int) $new_id; |
|
| 1076 | 1076 | Database::query($sql); |
| 1077 | 1077 | } |
| 1078 | 1078 | } |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
| 1135 | 1135 | $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
| 1136 | 1136 | |
| 1137 | - $params = (array)$topic->obj; |
|
| 1137 | + $params = (array) $topic->obj; |
|
| 1138 | 1138 | $params = self::DBUTF8_array($params); |
| 1139 | 1139 | $params['c_id'] = $this->destination_course_id; |
| 1140 | 1140 | $params['forum_id'] = $forum_id; |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | FROM $link_table |
| 1249 | 1249 | WHERE |
| 1250 | 1250 | c_id = ".$this->destination_course_id." AND |
| 1251 | - category_id='" . intval($cat_id). "'"; |
|
| 1251 | + category_id='" . intval($cat_id)."'"; |
|
| 1252 | 1252 | $result = Database::query($sql); |
| 1253 | 1253 | list($max_order) = Database::fetch_array($result); |
| 1254 | 1254 | |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | $params['description'] = self::DBUTF8($link->description); |
| 1264 | 1264 | $params['category_id'] = $cat_id; |
| 1265 | 1265 | $params['on_homepage'] = $link->on_homepage; |
| 1266 | - $params['display_order'] = $max_order+1; |
|
| 1266 | + $params['display_order'] = $max_order + 1; |
|
| 1267 | 1267 | |
| 1268 | 1268 | $id = Database::insert($link_table, $params); |
| 1269 | 1269 | |
@@ -1307,9 +1307,9 @@ discard block |
||
| 1307 | 1307 | if (is_object($link_cat) && !$link_cat->is_restored()) { |
| 1308 | 1308 | $sql = "SELECT MAX(display_order) FROM $link_cat_table |
| 1309 | 1309 | WHERE c_id = ".$this->destination_course_id; |
| 1310 | - $result=Database::query($sql); |
|
| 1311 | - list($orderMax)=Database::fetch_array($result,'NUM'); |
|
| 1312 | - $display_order=$orderMax+1; |
|
| 1310 | + $result = Database::query($sql); |
|
| 1311 | + list($orderMax) = Database::fetch_array($result, 'NUM'); |
|
| 1312 | + $display_order = $orderMax + 1; |
|
| 1313 | 1313 | |
| 1314 | 1314 | $params['c_id'] = $this->destination_course_id; |
| 1315 | 1315 | $params['category_title'] = self::DBUTF8($link_cat->title); |
@@ -1687,7 +1687,7 @@ discard block |
||
| 1687 | 1687 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
| 1688 | 1688 | $sql = "SELECT path FROM $table_doc |
| 1689 | 1689 | WHERE |
| 1690 | - c_id = " . $this->destination_course_id . " AND |
|
| 1690 | + c_id = ".$this->destination_course_id." AND |
|
| 1691 | 1691 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
| 1692 | 1692 | $doc = Database::query($sql); |
| 1693 | 1693 | $doc = Database::fetch_object($doc); |
@@ -1724,17 +1724,17 @@ discard block |
||
| 1724 | 1724 | 'random' => $quiz->random, |
| 1725 | 1725 | 'active' => $quiz->active, |
| 1726 | 1726 | 'sound' => self::DBUTF8($doc), |
| 1727 | - 'max_attempt' => (int)$quiz->max_attempt, |
|
| 1728 | - 'results_disabled' => (int)$quiz->results_disabled, |
|
| 1727 | + 'max_attempt' => (int) $quiz->max_attempt, |
|
| 1728 | + 'results_disabled' => (int) $quiz->results_disabled, |
|
| 1729 | 1729 | 'access_condition' => $quiz->access_condition, |
| 1730 | 1730 | 'pass_percentage' => $quiz->pass_percentage, |
| 1731 | - 'feedback_type' => (int)$quiz->feedback_type, |
|
| 1732 | - 'random_answers' => (int)$quiz->random_answers, |
|
| 1731 | + 'feedback_type' => (int) $quiz->feedback_type, |
|
| 1732 | + 'random_answers' => (int) $quiz->random_answers, |
|
| 1733 | 1733 | 'random_by_category' => $quiz->random_by_category, |
| 1734 | 1734 | 'review_answers' => $quiz->review_answers, |
| 1735 | 1735 | 'propagate_neg' => $quiz->propagate_neg, |
| 1736 | 1736 | 'text_when_finished' => $quiz->text_when_finished, |
| 1737 | - 'expired_time' => (int)$quiz->expired_time, |
|
| 1737 | + 'expired_time' => (int) $quiz->expired_time, |
|
| 1738 | 1738 | 'start_time' => $quiz->start_time, |
| 1739 | 1739 | 'end_time' => $quiz->end_time, |
| 1740 | 1740 | 'save_correct_answers' => 0, |
@@ -1774,10 +1774,10 @@ discard block |
||
| 1774 | 1774 | $qid = $this->restore_quiz_question($question_id); |
| 1775 | 1775 | $question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order; |
| 1776 | 1776 | $sql = "INSERT IGNORE INTO $table_rel SET |
| 1777 | - c_id = " . $this->destination_course_id . ", |
|
| 1777 | + c_id = ".$this->destination_course_id.", |
|
| 1778 | 1778 | question_id = $qid , |
| 1779 | 1779 | exercice_id = $new_id , |
| 1780 | - question_order = " . $question_order; |
|
| 1780 | + question_order = ".$question_order; |
|
| 1781 | 1781 | Database::query($sql); |
| 1782 | 1782 | } |
| 1783 | 1783 | } |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | $sql = "UPDATE $table_que SET |
| 1850 | 1850 | picture = '$picture_name' |
| 1851 | 1851 | WHERE |
| 1852 | - c_id = " . $this->destination_course_id . " AND |
|
| 1852 | + c_id = ".$this->destination_course_id." AND |
|
| 1853 | 1853 | id = $new_id "; |
| 1854 | 1854 | Database::query($sql); |
| 1855 | 1855 | } |
@@ -1861,7 +1861,7 @@ discard block |
||
| 1861 | 1861 | $allAnswers = []; |
| 1862 | 1862 | $onlyAnswers = []; |
| 1863 | 1863 | |
| 1864 | - if ($question->quiz_type == DRAGGABLE || $question->quiz_type == MATCHING ) { |
|
| 1864 | + if ($question->quiz_type == DRAGGABLE || $question->quiz_type == MATCHING) { |
|
| 1865 | 1865 | $allAnswers = array_column($question->answers, 'answer', 'id'); |
| 1866 | 1866 | } |
| 1867 | 1867 | |
@@ -2083,7 +2083,7 @@ discard block |
||
| 2083 | 2083 | $tab_test_category_id_old_new = array(); // used to build the quiz_question_rel_category table |
| 2084 | 2084 | if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) { |
| 2085 | 2085 | $resources = $this->course->resources; |
| 2086 | - foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory ) { |
|
| 2086 | + foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestCategory) { |
|
| 2087 | 2087 | $tab_test_category_id_old_new[$CourseCopyTestCategory->source_id] = $id; |
| 2088 | 2088 | // check if this test_category already exist in the destination BDD |
| 2089 | 2089 | // do not Database::escape_string $title and $description, it will be done later |
@@ -2234,7 +2234,7 @@ discard block |
||
| 2234 | 2234 | break; |
| 2235 | 2235 | case FILE_RENAME: |
| 2236 | 2236 | $survey_code = $survey->code.'_'; |
| 2237 | - $i=1; |
|
| 2237 | + $i = 1; |
|
| 2238 | 2238 | $temp_survey_code = $survey_code.$i; |
| 2239 | 2239 | while (!$this->is_survey_code_available($temp_survey_code)) { |
| 2240 | 2240 | $temp_survey_code = $survey_code.++$i; |
@@ -2266,15 +2266,15 @@ discard block |
||
| 2266 | 2266 | $sql = "SELECT * FROM $table_sur |
| 2267 | 2267 | WHERE |
| 2268 | 2268 | c_id = ".$this->destination_course_id." AND |
| 2269 | - survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
|
| 2269 | + survey_id='".self::DBUTF8escapestring(Database::result($result_check, 0, 0))."'"; |
|
| 2270 | 2270 | $result = Database::query($sql); |
| 2271 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
| 2271 | + $survey_data = Database::fetch_array($result, 'ASSOC'); |
|
| 2272 | 2272 | |
| 2273 | 2273 | // if the survey is shared => also delete the shared content |
| 2274 | 2274 | if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
| 2275 | - SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
|
| 2275 | + SurveyManager::delete_survey($survey_data['survey_share'], true, $this->destination_course_id); |
|
| 2276 | 2276 | } |
| 2277 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
| 2277 | + SurveyManager :: delete_survey($survey_data['survey_id'], false, $this->destination_course_id); |
|
| 2278 | 2278 | |
| 2279 | 2279 | // Insert the new source survey |
| 2280 | 2280 | $new_id = Database::insert($table_sur, $params); |
@@ -2459,13 +2459,13 @@ discard block |
||
| 2459 | 2459 | |
| 2460 | 2460 | // Adding the author's image |
| 2461 | 2461 | if (!empty($lp->preview_image)) { |
| 2462 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
| 2462 | + $new_filename = uniqid('').substr($lp->preview_image, strlen($lp->preview_image) - 7, strlen($lp->preview_image)); |
|
| 2463 | 2463 | if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
| 2464 | 2464 | $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
| 2465 | 2465 | if ($copy_result) { |
| 2466 | 2466 | $lp->preview_image = $new_filename; |
| 2467 | 2467 | } else { |
| 2468 | - $lp->preview_image =''; |
|
| 2468 | + $lp->preview_image = ''; |
|
| 2469 | 2469 | } |
| 2470 | 2470 | } |
| 2471 | 2471 | } |
@@ -2639,20 +2639,20 @@ discard block |
||
| 2639 | 2639 | $next_item_ids[$new_item_id] = $item['next_item_id']; |
| 2640 | 2640 | |
| 2641 | 2641 | if (!empty($item['prerequisite'])) { |
| 2642 | - if ($lp->lp_type =='2') { |
|
| 2642 | + if ($lp->lp_type == '2') { |
|
| 2643 | 2643 | // if is an sco |
| 2644 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
| 2644 | + $old_prerequisite[$new_item_id] = $item['prerequisite']; |
|
| 2645 | 2645 | } else { |
| 2646 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
| 2646 | + $old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']]; |
|
| 2647 | 2647 | } |
| 2648 | 2648 | } |
| 2649 | 2649 | |
| 2650 | 2650 | if (!empty($ref)) { |
| 2651 | - if ($lp->lp_type =='2') { |
|
| 2651 | + if ($lp->lp_type == '2') { |
|
| 2652 | 2652 | // if is an sco |
| 2653 | - $old_refs[$new_item_id]= $ref; |
|
| 2653 | + $old_refs[$new_item_id] = $ref; |
|
| 2654 | 2654 | } elseif (isset($new_item_ids[$ref])) { |
| 2655 | - $old_refs[$new_item_id]= $new_item_ids[$ref]; |
|
| 2655 | + $old_refs[$new_item_id] = $new_item_ids[$ref]; |
|
| 2656 | 2656 | } |
| 2657 | 2657 | } |
| 2658 | 2658 | |
@@ -2661,7 +2661,7 @@ discard block |
||
| 2661 | 2661 | |
| 2662 | 2662 | // Updating prerequisites |
| 2663 | 2663 | foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
| 2664 | - if ($my_old_prerequisite != ''){ |
|
| 2664 | + if ($my_old_prerequisite != '') { |
|
| 2665 | 2665 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
| 2666 | 2666 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
| 2667 | 2667 | Database::query($sql); |
@@ -2679,7 +2679,7 @@ discard block |
||
| 2679 | 2679 | |
| 2680 | 2680 | foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
| 2681 | 2681 | $parent_new_id = 0; |
| 2682 | - if($parent_item_old_id != 0){ |
|
| 2682 | + if ($parent_item_old_id != 0) { |
|
| 2683 | 2683 | $parent_new_id = $new_item_ids[$parent_item_old_id]; |
| 2684 | 2684 | } |
| 2685 | 2685 | $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
@@ -2688,7 +2688,7 @@ discard block |
||
| 2688 | 2688 | } |
| 2689 | 2689 | foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
| 2690 | 2690 | $previous_new_id = 0; |
| 2691 | - if ($previous_item_old_id != 0){ |
|
| 2691 | + if ($previous_item_old_id != 0) { |
|
| 2692 | 2692 | $previous_new_id = $new_item_ids[$previous_item_old_id]; |
| 2693 | 2693 | } |
| 2694 | 2694 | $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
@@ -2698,7 +2698,7 @@ discard block |
||
| 2698 | 2698 | |
| 2699 | 2699 | foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
| 2700 | 2700 | $next_new_id = 0; |
| 2701 | - if ($next_item_old_id != 0){ |
|
| 2701 | + if ($next_item_old_id != 0) { |
|
| 2702 | 2702 | $next_new_id = $new_item_ids[$next_item_old_id]; |
| 2703 | 2703 | } |
| 2704 | 2704 | $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
@@ -2708,7 +2708,7 @@ discard block |
||
| 2708 | 2708 | |
| 2709 | 2709 | foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
| 2710 | 2710 | $prerequisite_new_id = 0; |
| 2711 | - if ($prerequisite_old_id != 0){ |
|
| 2711 | + if ($prerequisite_old_id != 0) { |
|
| 2712 | 2712 | $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
| 2713 | 2713 | } |
| 2714 | 2714 | $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
@@ -2829,16 +2829,16 @@ discard block |
||
| 2829 | 2829 | if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue |
| 2830 | 2830 | while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue |
| 2831 | 2831 | if ($file != '.' && $file != '..') { |
| 2832 | - $path = $source . '/' . $file; |
|
| 2832 | + $path = $source.'/'.$file; |
|
| 2833 | 2833 | if (is_file($path)) { |
| 2834 | 2834 | /* if (!is_file($dest . '/' . $file) || $overwrite) |
| 2835 | 2835 | if (!@copy($path, $dest . '/' . $file)) { |
| 2836 | 2836 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
| 2837 | 2837 | }*/ |
| 2838 | - } elseif(is_dir($path)) { |
|
| 2839 | - if (!is_dir($dest . '/' . $file)) |
|
| 2840 | - mkdir($dest . '/' . $file); |
|
| 2841 | - self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite); |
|
| 2838 | + } elseif (is_dir($path)) { |
|
| 2839 | + if (!is_dir($dest.'/'.$file)) |
|
| 2840 | + mkdir($dest.'/'.$file); |
|
| 2841 | + self:: allow_create_all_directory($path, $dest.'/'.$file, $overwrite); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | } |
| 2844 | 2844 | } |
@@ -3036,7 +3036,7 @@ discard block |
||
| 3036 | 3036 | $this->course->backup_path, |
| 3037 | 3037 | $this->course->info['path'] |
| 3038 | 3038 | ); |
| 3039 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
| 3039 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
| 3040 | 3040 | unset($thematic->params['id']); |
| 3041 | 3041 | unset($thematic->params['iid']); |
| 3042 | 3042 | |
@@ -3060,7 +3060,7 @@ discard block |
||
| 3060 | 3060 | unset($thematic_advance['iid']); |
| 3061 | 3061 | $thematic_advance['attendance_id'] = 0; |
| 3062 | 3062 | $thematic_advance['thematic_id'] = $last_id; |
| 3063 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3063 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
| 3064 | 3064 | |
| 3065 | 3065 | $my_id = Database::insert( |
| 3066 | 3066 | $table_thematic_advance, |
@@ -3083,7 +3083,7 @@ discard block |
||
| 3083 | 3083 | } |
| 3084 | 3084 | } |
| 3085 | 3085 | |
| 3086 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3086 | + foreach ($thematic->thematic_plan_list as $thematic_plan) { |
|
| 3087 | 3087 | unset($thematic_plan['id']); |
| 3088 | 3088 | unset($thematic_plan['iid']); |
| 3089 | 3089 | $thematic_plan['thematic_id'] = $last_id; |
@@ -3199,7 +3199,7 @@ discard block |
||
| 3199 | 3199 | // re-create dir |
| 3200 | 3200 | // @todo check security against injection of dir in crafted course backup here! |
| 3201 | 3201 | $path = $obj->params['url']; |
| 3202 | - $path = '/'.str_replace('/','',substr($path,1)); |
|
| 3202 | + $path = '/'.str_replace('/', '', substr($path, 1)); |
|
| 3203 | 3203 | |
| 3204 | 3204 | $workData = array(); |
| 3205 | 3205 | switch ($this->file_option) { |
@@ -3221,9 +3221,9 @@ discard block |
||
| 3221 | 3221 | $obj->params['new_dir'] = $obj->params['title']; |
| 3222 | 3222 | |
| 3223 | 3223 | if (!empty($this->course_origin_id)) { |
| 3224 | - $sql = 'SELECT * FROM ' . $table_work_assignment . ' |
|
| 3224 | + $sql = 'SELECT * FROM '.$table_work_assignment.' |
|
| 3225 | 3225 | WHERE |
| 3226 | - c_id = ' . $this->course_origin_id . ' AND |
|
| 3226 | + c_id = ' . $this->course_origin_id.' AND |
|
| 3227 | 3227 | publication_id = ' . $id_work; |
| 3228 | 3228 | |
| 3229 | 3229 | $result = Database::query($sql); |
@@ -3334,7 +3334,7 @@ discard block |
||
| 3334 | 3334 | public function DBUTF8_array($array) |
| 3335 | 3335 | { |
| 3336 | 3336 | if (UTF8_CONVERT) { |
| 3337 | - foreach ($array as &$item) { |
|
| 3337 | + foreach ($array as &$item) { |
|
| 3338 | 3338 | $item = utf8_encode($item); |
| 3339 | 3339 | } |
| 3340 | 3340 | return $array; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | /** |
| 278 | 278 | * @param string |
| 279 | 279 | * @param string |
| 280 | - * @return true if the user is allowed to see the document, false otherwise |
|
| 280 | + * @return boolean if the user is allowed to see the document, false otherwise |
|
| 281 | 281 | * @author Sergio A Kessler, first version |
| 282 | 282 | * @author Roan Embrechts, bugfix |
| 283 | 283 | * @todo not only check if a file is visible, but also check if the user is allowed to see the file?? |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | * Return true if the documentpath have visibility=1 as |
| 1559 | 1559 | * item_property (you should use the is_visible_by_id) |
| 1560 | 1560 | * |
| 1561 | - * @param string $document_path the relative complete path of the document |
|
| 1561 | + * @param string $doc_path the relative complete path of the document |
|
| 1562 | 1562 | * @param array $course the _course array info of the document's course |
| 1563 | 1563 | * @param int |
| 1564 | 1564 | * @param string |
@@ -1644,6 +1644,7 @@ discard block |
||
| 1644 | 1644 | * @param int |
| 1645 | 1645 | * @param int |
| 1646 | 1646 | * @param bool |
| 1647 | + * @param integer $user_id |
|
| 1647 | 1648 | * @return bool |
| 1648 | 1649 | */ |
| 1649 | 1650 | public static function is_visible_by_id( |
@@ -1995,7 +1996,7 @@ discard block |
||
| 1995 | 1996 | * Remove default certificate |
| 1996 | 1997 | * @param string $course_id The course code |
| 1997 | 1998 | * @param int $default_certificate_id The document id of the default certificate |
| 1998 | - * @return void |
|
| 1999 | + * @return false|null |
|
| 1999 | 2000 | */ |
| 2000 | 2001 | public static function remove_attach_certificate($course_id, $default_certificate_id) |
| 2001 | 2002 | { |
@@ -2128,6 +2129,7 @@ discard block |
||
| 2128 | 2129 | * @param bool is file or string html |
| 2129 | 2130 | * @param string type (one of the app tools) - optional (otherwise takes the current item's type) |
| 2130 | 2131 | * @param int level of recursivity we're in |
| 2132 | + * @param string $source_html |
|
| 2131 | 2133 | * @return array List of file paths. An additional field containing 'local' or 'remote' helps determine |
| 2132 | 2134 | * if the file should be copied into the zip or just linked |
| 2133 | 2135 | */ |
@@ -2970,6 +2972,7 @@ discard block |
||
| 2970 | 2972 | |
| 2971 | 2973 | /** |
| 2972 | 2974 | * Obtains the text inside the file with the right parser |
| 2975 | + * @param string $doc_path |
|
| 2973 | 2976 | */ |
| 2974 | 2977 | public static function get_text_content($doc_path, $doc_mime) |
| 2975 | 2978 | { |
@@ -3221,6 +3224,7 @@ discard block |
||
| 3221 | 3224 | * Shows a play icon next to the document title in the document list |
| 3222 | 3225 | * @param int |
| 3223 | 3226 | * @param string |
| 3227 | + * @param integer|null $i |
|
| 3224 | 3228 | * @return string html content |
| 3225 | 3229 | */ |
| 3226 | 3230 | public static function generate_media_preview($i, $type = 'simple') |
@@ -4122,7 +4126,7 @@ discard block |
||
| 4122 | 4126 | } |
| 4123 | 4127 | |
| 4124 | 4128 | /** |
| 4125 | - * @return array |
|
| 4129 | + * @return string[] |
|
| 4126 | 4130 | */ |
| 4127 | 4131 | public static function get_web_odf_extension_list() |
| 4128 | 4132 | { |
@@ -4131,10 +4135,10 @@ discard block |
||
| 4131 | 4135 | |
| 4132 | 4136 | /** |
| 4133 | 4137 | * Set of extension allowed to use Jodconverter |
| 4134 | - * @param $mode 'from' |
|
| 4138 | + * @param string $mode 'from' |
|
| 4135 | 4139 | * 'to' |
| 4136 | 4140 | * 'all' |
| 4137 | - * @param $format 'text' |
|
| 4141 | + * @param string $format 'text' |
|
| 4138 | 4142 | * 'spreadsheet' |
| 4139 | 4143 | * 'presentation' |
| 4140 | 4144 | * 'drawing' |
@@ -4338,7 +4342,7 @@ discard block |
||
| 4338 | 4342 | } |
| 4339 | 4343 | |
| 4340 | 4344 | /** |
| 4341 | - * @return array |
|
| 4345 | + * @return string[] |
|
| 4342 | 4346 | */ |
| 4343 | 4347 | public static function get_system_folders() |
| 4344 | 4348 | { |
@@ -4356,7 +4360,7 @@ discard block |
||
| 4356 | 4360 | } |
| 4357 | 4361 | |
| 4358 | 4362 | /** |
| 4359 | - * @return array |
|
| 4363 | + * @return string[] |
|
| 4360 | 4364 | */ |
| 4361 | 4365 | public static function getProtectedFolderFromStudent() |
| 4362 | 4366 | { |
@@ -4512,7 +4516,7 @@ discard block |
||
| 4512 | 4516 | * Requires the ffmpeg lib. In ubuntu: sudo apt-get install ffmpeg |
| 4513 | 4517 | * @param string $wavFile |
| 4514 | 4518 | * @param bool $removeWavFileIfSuccess |
| 4515 | - * @return bool |
|
| 4519 | + * @return string|false |
|
| 4516 | 4520 | */ |
| 4517 | 4521 | public static function convertWavToMp3($wavFile, $removeWavFileIfSuccess = false) |
| 4518 | 4522 | { |
@@ -5088,6 +5092,8 @@ discard block |
||
| 5088 | 5092 | * @param string The current folder (path inside of the "document" directory, including the prefix "/") |
| 5089 | 5093 | * @param string Group directory, if empty, prevents documents to be uploaded (because group documents cannot be uploaded in root) |
| 5090 | 5094 | * @param boolean Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form) |
| 5095 | + * @param string $document_id |
|
| 5096 | + * @param FormValidator $form |
|
| 5091 | 5097 | |
| 5092 | 5098 | * @return string html form |
| 5093 | 5099 | */ |
@@ -5596,9 +5602,6 @@ discard block |
||
| 5596 | 5602 | /** |
| 5597 | 5603 | * Creates the row of edit icons for a file/folder |
| 5598 | 5604 | * |
| 5599 | - * @param string $curdirpath current path (cfr open folder) |
|
| 5600 | - * @param string $type (file/folder) |
|
| 5601 | - * @param string $path dbase path of file/folder |
|
| 5602 | 5605 | * @param int $visibility (1/0) |
| 5603 | 5606 | * @param int $id dbase id of the document |
| 5604 | 5607 | * @return string html img tags with hyperlinks |
@@ -5947,7 +5950,7 @@ discard block |
||
| 5947 | 5950 | /** |
| 5948 | 5951 | * Gets the path translated with title of docs and folders |
| 5949 | 5952 | * @param string $path the real path |
| 5950 | - * @return the path which should be displayed |
|
| 5953 | + * @return string path which should be displayed |
|
| 5951 | 5954 | */ |
| 5952 | 5955 | public static function get_titles_of_path($path) |
| 5953 | 5956 | { |
@@ -6003,7 +6006,8 @@ discard block |
||
| 6003 | 6006 | |
| 6004 | 6007 | /** |
| 6005 | 6008 | * Checks whether the user is in shared folder |
| 6006 | - * @return return bool Return true when user is into shared folder |
|
| 6009 | + * @param integer $current_session_id |
|
| 6010 | + * @return boolean bool Return true when user is into shared folder |
|
| 6007 | 6011 | */ |
| 6008 | 6012 | public static function is_shared_folder($curdirpath, $current_session_id) |
| 6009 | 6013 | { |
@@ -6019,7 +6023,7 @@ discard block |
||
| 6019 | 6023 | |
| 6020 | 6024 | /** |
| 6021 | 6025 | * Checks whether the user is into any user shared folder |
| 6022 | - * @return return bool Return true when user is in any user shared folder |
|
| 6026 | + * @return boolean bool Return true when user is in any user shared folder |
|
| 6023 | 6027 | */ |
| 6024 | 6028 | public static function is_any_user_shared_folder($path, $current_session_id) |
| 6025 | 6029 | { |
@@ -6233,7 +6237,7 @@ discard block |
||
| 6233 | 6237 | * @param int $id |
| 6234 | 6238 | * @param array $courseInfo |
| 6235 | 6239 | * @param int $sessionId |
| 6236 | - * @return bool |
|
| 6240 | + * @return boolean|null |
|
| 6237 | 6241 | */ |
| 6238 | 6242 | public static function downloadDeletedDocument($id, $courseInfo, $sessionId) |
| 6239 | 6243 | { |
@@ -6252,7 +6256,7 @@ discard block |
||
| 6252 | 6256 | * @param array $courseInfo |
| 6253 | 6257 | * @param int $sessionId |
| 6254 | 6258 | * |
| 6255 | - * @return bool |
|
| 6259 | + * @return false|null |
|
| 6256 | 6260 | */ |
| 6257 | 6261 | public static function downloadAllDeletedDocument($courseInfo, $sessionId) |
| 6258 | 6262 | { |
@@ -6291,7 +6295,7 @@ discard block |
||
| 6291 | 6295 | * @param array $courseInfo |
| 6292 | 6296 | * @param int $sessionId |
| 6293 | 6297 | * |
| 6294 | - * @return bool |
|
| 6298 | + * @return false|null |
|
| 6295 | 6299 | */ |
| 6296 | 6300 | public static function deleteDocumentsFromSession($courseInfo, $sessionId) |
| 6297 | 6301 | { |
@@ -1263,6 +1263,7 @@ discard block |
||
| 1263 | 1263 | * Gets the list of courses a specific user is subscribed to |
| 1264 | 1264 | * @param int User ID |
| 1265 | 1265 | * @param boolean $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED |
| 1266 | + * @param integer $userid |
|
| 1266 | 1267 | * @return array Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d) |
| 1267 | 1268 | */ |
| 1268 | 1269 | function api_get_user_courses($userid, $fetch_session = true) |
@@ -3024,7 +3025,7 @@ discard block |
||
| 3024 | 3025 | * on the session visibility |
| 3025 | 3026 | * @param bool $tutor Whether to check if the user has the tutor role |
| 3026 | 3027 | * @param bool $coach Whether to check if the user has the coach role |
| 3027 | -* @return boolean true: the user has the rights to edit, false: he does not |
|
| 3028 | +* @return boolean|null true: the user has the rights to edit, false: he does not |
|
| 3028 | 3029 | */ |
| 3029 | 3030 | function api_is_allowed_to_session_edit($tutor = false, $coach = false) |
| 3030 | 3031 | { |
@@ -4199,6 +4200,7 @@ discard block |
||
| 4199 | 4200 | /** |
| 4200 | 4201 | * Returns the id (the database id) of a language |
| 4201 | 4202 | * @param string language name (the corresponding name of the language-folder in the filesystem) |
| 4203 | + * @param string $language |
|
| 4202 | 4204 | * @return int id of the language |
| 4203 | 4205 | */ |
| 4204 | 4206 | function api_get_language_id($language) |
@@ -5207,6 +5209,7 @@ discard block |
||
| 5207 | 5209 | * @param string Whether we want a simple list (display a category) or |
| 5208 | 5210 | * a grouped list (group by variable as in settings.php default). Values: 'list' or 'group' |
| 5209 | 5211 | * @param int Access URL's ID. Optional. Uses 1 by default, which is the unique URL |
| 5212 | + * @param string $cat |
|
| 5210 | 5213 | * @return array Array of database results for the current settings of the current access URL |
| 5211 | 5214 | */ |
| 5212 | 5215 | function &api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0) |
@@ -6285,7 +6288,7 @@ discard block |
||
| 6285 | 6288 | * |
| 6286 | 6289 | * Returns the <link> HTML tag |
| 6287 | 6290 | * |
| 6288 | - * @param $file |
|
| 6291 | + * @param string $file |
|
| 6289 | 6292 | * @param string $media |
| 6290 | 6293 | * @return string |
| 6291 | 6294 | */ |
@@ -6608,7 +6611,7 @@ discard block |
||
| 6608 | 6611 | /** |
| 6609 | 6612 | * Returns an array of global configuration settings which should be ignored |
| 6610 | 6613 | * when printing the configuration settings screens |
| 6611 | - * @return array Array of strings, each identifying one of the excluded settings |
|
| 6614 | + * @return string[] Array of strings, each identifying one of the excluded settings |
|
| 6612 | 6615 | */ |
| 6613 | 6616 | function api_get_locked_settings() { |
| 6614 | 6617 | return array( |
@@ -6649,6 +6652,7 @@ discard block |
||
| 6649 | 6652 | * false if he isn't. If the user ID is given and is an integer, then the same |
| 6650 | 6653 | * ID is simply returned |
| 6651 | 6654 | * @param integer User ID |
| 6655 | + * @param integer $user_id |
|
| 6652 | 6656 | * @return boolean Integer User ID is logged in, or false otherwise |
| 6653 | 6657 | */ |
| 6654 | 6658 | function api_user_is_login($user_id = null) { |
@@ -7069,6 +7073,7 @@ discard block |
||
| 7069 | 7073 | /** |
| 7070 | 7074 | * Gets memory limit in bytes |
| 7071 | 7075 | * @param string The memory size (128M, 1G, 1000K, etc) |
| 7076 | + * @param string $mem |
|
| 7072 | 7077 | * @return int |
| 7073 | 7078 | * @assert (null) === false |
| 7074 | 7079 | * @assert ('1t') === 1099511627776 |