| @@ 2611-2637 (lines=27) @@ | ||
| 2608 | if (file_exists($origin_filepath)) { |
|
| 2609 | $filepath_dir = dirname($destination_filepath); |
|
| 2610 | ||
| 2611 | if (!is_dir($filepath_dir)) { |
|
| 2612 | $perm = api_get_permissions_for_new_directories(); |
|
| 2613 | $result = @mkdir($filepath_dir, $perm, true); |
|
| 2614 | if ($result) { |
|
| 2615 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir); |
|
| 2616 | ||
| 2617 | //Add to item properties to the new folder |
|
| 2618 | $doc_id = add_document( |
|
| 2619 | $destination_course_info, |
|
| 2620 | $filepath_to_add, |
|
| 2621 | 'folder', |
|
| 2622 | 0, |
|
| 2623 | basename($filepath_to_add) |
|
| 2624 | ); |
|
| 2625 | api_item_property_update( |
|
| 2626 | $destination_course_info, |
|
| 2627 | TOOL_DOCUMENT, |
|
| 2628 | $doc_id, |
|
| 2629 | 'FolderCreated', |
|
| 2630 | $user_id, |
|
| 2631 | null, |
|
| 2632 | null, |
|
| 2633 | null, |
|
| 2634 | null |
|
| 2635 | ); |
|
| 2636 | } |
|
| 2637 | } |
|
| 2638 | ||
| 2639 | if (!file_exists($destination_filepath)) { |
|
| 2640 | $result = @copy($origin_filepath, $destination_filepath); |
|
| @@ 2639-2665 (lines=27) @@ | ||
| 2636 | } |
|
| 2637 | } |
|
| 2638 | ||
| 2639 | if (!file_exists($destination_filepath)) { |
|
| 2640 | $result = @copy($origin_filepath, $destination_filepath); |
|
| 2641 | if ($result) { |
|
| 2642 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $destination_filepath); |
|
| 2643 | $size = filesize($destination_filepath); |
|
| 2644 | ||
| 2645 | // Add to item properties to the file |
|
| 2646 | $doc_id = add_document( |
|
| 2647 | $destination_course_info, |
|
| 2648 | $filepath_to_add, |
|
| 2649 | 'file', |
|
| 2650 | $size, |
|
| 2651 | basename($filepath_to_add) |
|
| 2652 | ); |
|
| 2653 | api_item_property_update( |
|
| 2654 | $destination_course_info, |
|
| 2655 | TOOL_DOCUMENT, |
|
| 2656 | $doc_id, |
|
| 2657 | 'FolderCreated', |
|
| 2658 | $user_id, |
|
| 2659 | null, |
|
| 2660 | null, |
|
| 2661 | null, |
|
| 2662 | null |
|
| 2663 | ); |
|
| 2664 | } |
|
| 2665 | } |
|
| 2666 | } |
|
| 2667 | ||
| 2668 | // Replace origin course path by destination course path. |
|