@@ 2571-2597 (lines=27) @@ | ||
2568 | if (file_exists($origin_filepath)) { |
|
2569 | $filepath_dir = dirname($destination_filepath); |
|
2570 | ||
2571 | if (!is_dir($filepath_dir)) { |
|
2572 | $perm = api_get_permissions_for_new_directories(); |
|
2573 | $result = @mkdir($filepath_dir, $perm, true); |
|
2574 | if ($result) { |
|
2575 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir); |
|
2576 | ||
2577 | //Add to item properties to the new folder |
|
2578 | $doc_id = add_document( |
|
2579 | $destination_course_info, |
|
2580 | $filepath_to_add, |
|
2581 | 'folder', |
|
2582 | 0, |
|
2583 | basename($filepath_to_add) |
|
2584 | ); |
|
2585 | api_item_property_update( |
|
2586 | $destination_course_info, |
|
2587 | TOOL_DOCUMENT, |
|
2588 | $doc_id, |
|
2589 | 'FolderCreated', |
|
2590 | $user_id, |
|
2591 | null, |
|
2592 | null, |
|
2593 | null, |
|
2594 | null |
|
2595 | ); |
|
2596 | } |
|
2597 | } |
|
2598 | ||
2599 | if (!file_exists($destination_filepath)) { |
|
2600 | $result = @copy($origin_filepath, $destination_filepath); |
|
@@ 2599-2625 (lines=27) @@ | ||
2596 | } |
|
2597 | } |
|
2598 | ||
2599 | if (!file_exists($destination_filepath)) { |
|
2600 | $result = @copy($origin_filepath, $destination_filepath); |
|
2601 | if ($result) { |
|
2602 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $destination_filepath); |
|
2603 | $size = filesize($destination_filepath); |
|
2604 | ||
2605 | // Add to item properties to the file |
|
2606 | $doc_id = add_document( |
|
2607 | $destination_course_info, |
|
2608 | $filepath_to_add, |
|
2609 | 'file', |
|
2610 | $size, |
|
2611 | basename($filepath_to_add) |
|
2612 | ); |
|
2613 | api_item_property_update( |
|
2614 | $destination_course_info, |
|
2615 | TOOL_DOCUMENT, |
|
2616 | $doc_id, |
|
2617 | 'FolderCreated', |
|
2618 | $user_id, |
|
2619 | null, |
|
2620 | null, |
|
2621 | null, |
|
2622 | null |
|
2623 | ); |
|
2624 | } |
|
2625 | } |
|
2626 | } |
|
2627 | ||
2628 | // Replace origin course path by destination course path. |